realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.77k stars 573 forks source link

Web SDK collection.watch() method causes Jest tests not to finish #4401

Open mongodben opened 2 years ago

mongodben commented 2 years ago

How frequently does the bug occur?

All the time. Using the Web SDK

Description

Jest doesn't exit when using the Web SDK MongoDB connector's collection.watch() method (docs). see below for error method.

when i skip the tests that use collection.watch(), tests run and exit as expected.

Stacktrace & log output

Test Suites: 15 passed, 15 total
Tests:       21 skipped, 44 passed, 65 total
Snapshots:   0 total
Time:        26.794 s
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.

Can you reproduce the bug?

Yes, always

Reproduction Steps

see https://github.com/mongodben/docs-realm/blob/test_web_gh_action/examples/web/src/__tests__/mongodb-data-access.test.js#L336-L429

Version

Web SDK - 1.7.0

What SDK flavour are you using?

MongoDB Realm (i.e. Sync, auth, functions)

Are you using encryption?

No, not using encryption

Platform OS and version(s)

MacOS 11.6.3

Build environment

Jest test runner in Create React App with the Web SDK

Cocoapods version

No response

kneth commented 2 years ago

As a work-around you can add --forceExit to the list of command-line options for Jest. We will have to investigate further in order to understand the underlaying issue.