Jest tests with jest.resetModules() fails after upgrade to 2.2.4
See original GitHub issueGoals
update to realm@2.2.4
Expected Results
Successful test
Actual Results
got error from test with realm imported
TypeError: Cannot redefine property: Worker
at Function.defineProperty (native)
> 1 | import Realm from 'realm';
Steps to Reproduce
- install realm2.2.4
import Realm from 'realm';
describe("Testing realm", () => {
beforeEach(() => {
jest.resetModules();
});
test("realm", () => {
const realm2 = require('realm')
})
})
- run test
Version of Realm and Tooling
- Realm JS SDK Version: 2.2.4
- Node or React Native: React native jest
- Client OS & Version: Windows
- Which debugger for React Native: None
Adding configurable: true in realm/lib/index.js’s Object.defineProperty(realmConstructor fixes the issue. Not sure if this is a bug. Can you provide a workaround?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Jest not working properly after upgrading to react-scripts@4.0.3
With resetMocks: false my mocks seem to not be reset which is expected but my mocks seem to be present after the test...
Read more >babel-jest - Awesome JS
[docs] Update link to Jest 28 upgrade guide in error message (#13483); [jest-runner, ... [@jest/cli, jest-config] A seed for the test run will...
Read more >Configuring Jest
The bail config option can be used here to have Jest stop running tests after n failures. Setting bail to true is the...
Read more >The 4 stages of flakiness (part 2/3): log failed tests with a Jest ...
The story so far: we have flaky tests and want to log failures so everything can be rerun later. Have a look at...
Read more >@jest/core: Versions | Openbase
[docs] Update link to Jest 28 upgrade guide in error message (#13483) ... each to failing tests by @kkyusufk in https://github.com/facebook/jest/pull/13142 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I close the issue as #1695 has been merged and released as part of 2.2.15.
I have merged #1723 but we need to backport it to the 2.2.x series (branch
2.2.x
).