Skip to content

FilesViewer - Flaky test  #2910

@cballevre

Description

@cballevre

Lately we have trouble with the CI because of a flaky test. I put it in quarantine until I can fix it (cf: commit). This issue aims to follow the resolution of this problem.

Error traces
FAIL src/drive/web/modules/viewer/FilesViewer.spec.jsx

 FilesViewer  should fetch more files if necessary

This test called the console which is forbidden.

Here is what have been logged:

console.error

Warning: An update to %s 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://fb.me/react-wrap-tests-with-act%s FilesViewer 
  in FilesViewer
  in FabProvider (created by AppLike)
  in BreakpointsProvider (created by AppLike)
  in ThumbnailSizeContextProvider (created by AppLike)
  in AcceptingSharingProvider (created by AppLike)
  in I18n (created by TestI18n)
  in TestI18n (created by AppLike)
  in CozyProvider (created by AppLike)
  in Provider (created by AppLike)
  in AppLike (created by WrapperComponent)
  in WrapperComponent

If calling the console is normal in your test case, consider mocking the console as is:

jest.spyOn(console, 'method').mockImplementation();

afterEach(() => {
  if (consoleCalls.length > 0) {
    throw new Error(
               ^
         red(\`
This test called the console which is forbidden.

at Object.<anonymous> (jestHelpers/ConsoleUsageReporter.js:109:15)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions