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

Test unit in v3 create open handles in Jest for every test #1041

Closed
kopax-polyconseil opened this issue Apr 13, 2021 · 3 comments
Closed

Test unit in v3 create open handles in Jest for every test #1041

kopax-polyconseil opened this issue Apr 13, 2021 · 3 comments
Labels

Comments

@kopax-polyconseil
Copy link

kopax-polyconseil commented Apr 13, 2021

Following #1022, I have created two separate bug identified in v3.

Describe the bug

Since we migrated to v3, each test of our app hang and the following warning appear :

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

To Reproduce

This is how:

Expected behavior

We expect our test to close when they finish, instead we have open handles which cause our whole tests suite to take 7min instead of 4.

Additional context

@semoal
Copy link
Contributor

semoal commented Apr 13, 2021

Hey Dimitri! Hope you had a good weekend.

This is already a known issue #899, didn't know how to fix it "easily".

Meanwhile a workaround for the testing suite it's just:

const LinguiProvider: React.FC = ({ children }) => {
  return (
    <I18nProvider i18n={i18n} forceRenderOnLocaleChange={false}>
      {children}
    </I18nProvider>
  )
}

forcingRenderOnLocaleChange to false in this way the i18n.activate() will just run once, if the locale doesn't change, in your case it's always fr so..

I've tried your codebase and the time:

Test Suites: 228 passed, 228 total
Tests:       5 skipped, 1308 passed, 1313 total
Snapshots:   90 passed, 90 total
Time:        70.639s, estimated 92s

More or less 1 minute, not bad at all for 1313 tests ;)

@kopax-polyconseil
Copy link
Author

Hi @semoal and thanks, I hope you had a good week-end too.

I am checking the workaround now.

You are lucky cause my test without --runInBand locally takes Time: 106.702s

Our CI takes even more time, 219.71s + 291.29s :

Time:        219.71s
Ran all test suites.
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

If you try to run the test with yarn run test:unit --runInBand locally (as in our CI), you will also have the test process hanging.

@stale
Copy link

stale bot commented Jun 12, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 12, 2021
@stale stale bot closed this as completed Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants