Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: slow imports › usePageLoadingContext possible flakey unit test #9107

Open
virtuoushub opened this issue Aug 31, 2023 · 2 comments
Open

Comments

@virtuoushub
Copy link
Collaborator

virtuoushub commented Aug 31, 2023

possible flakey test:

test code: https://github.com/redwoodjs/redwood/blob/main/packages/router/src/__tests__/router.test.tsx#L502-L545

FAIL   code  src/__tests__/router.test.tsx (50.835 s)
  ● slow imports › usePageLoadingContext

    expect(element).not.toBeInTheDocument()

    expected document not to contain element, found <p>loading in page...</p> instead

      536 |       // This shouldn't show up, because the page shouldn't render before it's
      537 |       // fully loaded
    > 538 |       expect(screen.queryByText('loading in page...')).not.toBeInTheDocument()
          |                                                            ^
      539 |
      540 |       await waitFor(() => screen.getByText('done loading in page'))
      541 |       await waitFor(() => screen.getByText('done loading in layout'))

      at Object.toBeInTheDocument (src/__tests__/router.test.tsx:538:60)

see: https://github.com/redwoodjs/redwood/actions/runs/6032779642/job/16368480189#step:10:342

Originally posted by @virtuoushub in #9082 (comment)

@virtuoushub virtuoushub changed the title slow imports › usePageLoadingContext possible flakey unit test [Bug?]: slow imports › usePageLoadingContext possible flakey unit test Aug 31, 2023
@Josh-Walker-GM
Copy link
Collaborator

Josh-Walker-GM commented Aug 31, 2023

I've been seeing this once or twice too 👍

Eg: https://github.com/redwoodjs/redwood/actions/runs/6038395635/job/16390496793?pr=9104
Eg: https://github.com/redwoodjs/redwood/actions/runs/6040265077/job/16390819253?pr=9058

@virtuoushub
Copy link
Collaborator Author

wonder if this is a better candidate for a integration test rather than a unit? All that mocking of delays in jest seems too synthetic and tricky to get right.

Cypress and Playwright seem like a better place for this type of test imho, even though from what I can tell we might still run into a similar issue; but it seems closer to real world use cases in an integration test than a unit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants