question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jest tests with jest.resetModules() fails after upgrade to 2.2.4

See original GitHub issue

Goals

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

  1. install realm2.2.4
import Realm from 'realm';
describe("Testing realm", () => {
    beforeEach(() => {
        jest.resetModules();
    });
    test("realm", () => {
        const realm2 = require('realm')
    })
})
  1. 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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
knethcommented, Mar 9, 2018

I close the issue as #1695 has been merged and released as part of 2.2.15.

0reactions
knethcommented, Apr 3, 2018

I have merged #1723 but we need to backport it to the 2.2.x series (branch 2.2.x).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found