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

FilesViewer - Flaky test #2910

Open
cballevre opened this issue May 9, 2023 · 2 comments
Open

FilesViewer - Flaky test #2910

cballevre opened this issue May 9, 2023 · 2 comments

Comments

@cballevre
Copy link
Member

cballevre commented May 9, 2023

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)
cballevre added a commit that referenced this issue Jul 11, 2023
Without the await, the getEncryptionKeyFromDirId function is never called because the file is not considered to be encrypted. I followed the previous tests to solve the problem

This commit also removes the flaky test reported in issue #2910
cballevre added a commit that referenced this issue Jul 11, 2023
Without the await, the getEncryptionKeyFromDirId function is never called because the file is not considered to be encrypted. I followed the previous tests to solve the problem

This commit also removes the flaky test reported in issue #2910
cballevre added a commit that referenced this issue Jul 11, 2023
Without the await, the getEncryptionKeyFromDirId function is never called because the file is not considered to be encrypted. I followed the previous tests to solve the problem

This commit also removes the flaky test reported in issue #2910
cballevre added a commit that referenced this issue Jul 11, 2023
Without the await, the getEncryptionKeyFromDirId function is never called because the file is not considered to be encrypted. I followed the previous tests to solve the problem

This commit also removes the flaky test reported in issue #2910
cballevre added a commit that referenced this issue Jul 11, 2023
Without the await, the getEncryptionKeyFromDirId function is never called because the file is not considered to be encrypted. I followed the previous tests to solve the problem

This commit also removes the flaky test reported in issue #2910
@cballevre
Copy link
Member Author

Normally converting enzyme to react-testing-library fix this issue (cf: commit)

cballevre added a commit that referenced this issue Jul 24, 2023
This test file still creates a flaky test, so I'm skipping it until I figure out how to fix it #2910
@cballevre cballevre reopened this Jul 24, 2023
@cballevre
Copy link
Member Author

There is stil a flaky test in FilesViewer. The error comes from the number of calls to the jest.fn() function in the fetchMore test. When you run the test file alone there is no problem but as soon as it is with all the tests it can cause a problem

cballevre added a commit that referenced this issue Jul 24, 2023
This test file still creates a flaky test, so I'm skipping it until I figure out how to fix it 

See issue #2910
cballevre added a commit that referenced this issue Jul 24, 2023
This test file still creates a flaky test, so I'm skipping it until I figure out how to fix it 

See issue #2910
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

1 participant