Skip to content

Intermittent JS test timeouts #98

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

Closed
mbertrand opened this issue Sep 21, 2023 · 0 comments · Fixed by #100
Closed

Intermittent JS test timeouts #98

mbertrand opened this issue Sep 21, 2023 · 0 comments · Fixed by #100
Assignees
Labels
bug Something isn't working

Comments

@mbertrand
Copy link
Member

Maybe increase the timeout value?

AIL frontends/mit-open/src/pages/learningpaths/LearningPathDetails.test.ts (17.494 s)
  ● LearningPathDetailsPage › Clicking reorder makes items reorderable, clicking Done makes them static

    thrown: "Exceeded timeout of 5000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

       97 |   )
       98 |
    >  99 |   test("Clicking reorder makes items reorderable, clicking Done makes them static", async () => {
          |   ^
      100 |     const path = factories.learningResources.learningPath()
      101 |     setup({ path, userSettings: { is_learning_path_editor: true } })
      102 |     const reorderButton = await screen.findByRole("button", { name: "Reorder" })

      at test (pages/learningpaths/LearningPathDetails.test.ts:99:3)
      at Object.describe (pages/learningpaths/LearningPathDetails.test.ts:68:1)

  ● LearningPathDetailsPage › Edit buttons opens editing dialog

    Expected test not to call console.error().

    If the error is expected, test for it explicitly by mocking it out using jest.spyOn(console, 'error').mockImplementation() and test that the warning occurs.

    Warning: An update to LearningPathDetailsPage inside a test was not wrapped in act(...).

    When testing, code that causes React state updates should be wrapped into act(...):

    act(() => {
      /* fire events that update state */
    });
    /* assert on the output */

    This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act

      24 |
      [25](https://github.com/mitodl/mit-open/actions/runs/6264174151/job/17010280208?pr=84#step:12:26) | const LearningPathDetailsPage: React.FC = () => {
    > [26](https://github.com/mitodl/mit-open/actions/runs/6264174151/job/17010280208?pr=84#step:12:27) |   const id = Number(useParams<RouteParams>().id)
         |                     ^
      [27](https://github.com/mitodl/mit-open/actions/runs/6264174151/job/17010280208?pr=84#step:12:28) |   const pathQuery = useLearningPathsDetail(id)
      [28](https://github.com/mitodl/mit-open/actions/runs/6264174151/job/17010280208?pr=84#step:12:29) |   const itemsQuery = useInfiniteLearningPathItems({ parent_id: id })
      [29](https://github.com/mitodl/mit-open/actions/runs/6264174151/job/17010280208?pr=84#step:12:30) |   const [isSorting, toggleIsSorting] = useToggle(false)

      at useParams (pages/learningpaths/LearningPathDetails.tsx:26:21)
      at Route (../../../node_modules/react-router/cjs/react-router.js:664:29)
      at Switch (../../../node_modules/react-router/cjs/react-router.js:866:29)
      at children (pages/errors/ErrorPageRedirect.tsx:15:3)
      at InnerContextProvider (../../../node_modules/@ebay/nice-modal-react/src/index.tsx:447:51)
      at Provider (../../../node_modules/@ebay/nice-modal-react/src/index.tsx:460:11)
      at Router (../../../node_modules/react-router/cjs/react-router.js:283:[30](https://github.com/mitodl/mit-open/actions/runs/6264174151/job/17010280208?pr=84#step:12:31))
      at e (../../../node_modules/react-helmet-async/src/Provider.js:42:3)
      at QueryClientProvider (../../../node_modules/@tanstack/react-query/build/lib/QueryClientProvider.js:65:3)
      at InnerThemeProvider (../../../node_modules/@mui/system/ThemeProvider/ThemeProvider.js:29:39)
      at ThemeProvider (../../../node_modules/@mui/private-theming/node/ThemeProvider/ThemeProvider.js:55:5)
      at ThemeProvider (../../../node_modules/@mui/system/ThemeProvider/ThemeProvider.js:49:5)
      at history (App.tsx:33:3)
          at div
      at history (App.tsx:56:36)
      at console.captureMessage [as error] (../../../node_modules/jest-fail-on-console/index.js:55:25)
      at printWarning (../../../node_modules/react-dom/cjs/react-dom.development.js:86:30)
      at error (../../../node_modules/react-dom/cjs/react-dom.development.js:60:7)
      at warnIfUpdatesNotWrappedWithActDEV (../../../node_modules/react-dom/cjs/react-dom.development.js:27589:9)
      at scheduleUpdateOnFiber (../../../node_modules/react-dom/cjs/react-dom.development.js:25508:5)
      at forceStoreRerender (../../../node_modules/react-dom/cjs/react-dom.development.js:16977:5)
      at handleStoreChange (../../../node_modules/react-dom/cjs/react-dom.development.js:16953:7)
      at callback (../../../node_modules/@tanstack/query-core/src/notifyManager.ts:55:9)
      at callback (../../../node_modules/@tanstack/query-core/src/notifyManager.ts:17:5)
      at notifyFn (../../../node_modules/@tanstack/query-core/src/notifyManager.ts:67:13)
          at Array.forEach (<anonymous>)
      at forEach (../../../node_modules/@tanstack/query-core/src/notifyManager.ts:66:25)
      at batchedUpdates$1 (../../../node_modules/react-dom/cjs/react-dom.development.js:26140:12)
      at batchNotifyFn (../../../node_modules/@tanstack/query-core/src/notifyManager.ts:65:9)
      Warning: An update to ForwardRef(ButtonBase) inside a test was not wrapped in act(...).
      When testing, code that causes React state updates should be wrapped into act(...):
      act(() => {
        /* fire events that update state */
      });
      at QueryClientProvider (../../../node_modules/@tanstack/react-query/build/lib/QueryClientProvider.js:65:3)
      at InnerThemeProvider (../../../node_modules/@mui/system/ThemeProvider/ThemeProvider.js:29:39)
      at ThemeProvider (../../../node_modules/@mui/private-theming/node/ThemeProvider/ThemeProvider.js:55:5)
      at ThemeProvider (../../../node_modules/@mui/system/ThemeProvider/ThemeProvider.js:49:5)
      at history (App.tsx:33:3)
          at div
      at history (App.tsx:56:36)
      at console.captureMessage [as error] (../../../node_modules/jest-fail-on-console/index.js:55:25)
      at printWarning (../../../node_modules/react-dom/cjs/react-dom.development.js:86:30)
      at error (../../../node_modules/react-dom/cjs/react-dom.development.js:60:7)
      at warnIfUpdatesNotWrappedWithActDEV (../../../node_modules/react-dom/cjs/react-dom.development.js:27589:9)
      at scheduleUpdateOnFiber (../../../node_modules/react-dom/cjs/react-dom.development.js:25508:5)
      at Object.enqueueSetState (../../../node_modules/react-dom/cjs/react-dom.development.js:14067:7)
      at TransitionGroup.Object.<anonymous>.Component.setState (../../../node_modules/react/cjs/react.development.js:354:16)
      at TransitionGroup.componentDidMount (../../../node_modules/react-transition-group/cjs/TransitionGroup.js:76:10)
      at invokeLayoutEffectMountInDEV (../../../node_modules/react-dom/cjs/react-dom.development.js:25133:22)
      at invokeEffectsInDev (../../../node_modules/react-dom/cjs/react-dom.development.js:27351:11)
      at commitDoubleInvokeEffectsInDEV (../../../node_modules/react-dom/cjs/react-dom.development.js:27[32](https://github.com/mitodl/mit-open/actions/runs/6264174151/job/17010280208?pr=84#step:12:33)7:5)
      at flushPassiveEffectsImpl (../../../node_modules/react-dom/cjs/react-dom.development.js:27056:5)
      at flushPassiveEffects (../../../node_modules/react-dom/cjs/react-dom.development.js:26984:14)
      at performSyncWorkOnRoot (../../../node_modules/react-dom/cjs/react-dom.development.js:26076:3)
      at flushSyncCallbacks (../../../node_modules/react-dom/cjs/react-dom.development.js:12042:22)
      at commitRootImpl (../../../node_modules/react-dom/cjs/react-dom.development.js:26959:3)
      at commitRoot (../../../node_modules/react-dom/cjs/react-dom.development.js:26682:5)
      at finishConcurrentRender (../../../node_modules/react-dom/cjs/react-dom.development.js:25981:9)
      at performConcurrentWorkOnRoot (../../../node_modules/react-dom/cjs/react-dom.development.js:25809:7)
      at workLoop (../../../node_modules/scheduler/cjs/scheduler.development.js:266:34)
      at flushWork (../../../node_modules/scheduler/cjs/scheduler.development.js:239:14)
      at performWorkUntilDeadline (../../../node_modules/scheduler/cjs/scheduler.development.js:5[33](https://github.com/mitodl/mit-open/actions/runs/6264174151/job/17010280208?pr=84#step:12:34):21)
      at Timeout.task [as _onTimeout] (../../../node_modules/jsdom/lib/jsdom/browser/Window.js:520:19)
      at flushUnexpectedConsoleCalls (../../../node_modules/jest-fail-on-console/index.js:[39](https://github.com/mitodl/mit-open/actions/runs/6264174151/job/17010280208?pr=84#step:12:40):13)
      at Object.<anonymous> (../../../node_modules/jest-fail-on-console/index.js:[79](https://github.com/mitodl/mit-open/actions/runs/6264174151/job/17010280208?pr=84#step:12:80):7)

@mbertrand mbertrand added the bug Something isn't working label Sep 21, 2023
@ChristopherChudzicki ChristopherChudzicki self-assigned this Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants