facebook-atom / jest-electron-runner

custom test runner for Jest that allows tests to be run in Electron environment
MIT License
189 stars 33 forks source link

Mocks are undefined when using electron-runner 3.0.0 or 2.0.3 in combination with Jest 25+ #65

Open dschuessler opened 4 years ago

dschuessler commented 4 years ago

Steps to reproduce:

  1. Clone this repository: https://github.com/dschuessler/jest-bug-example
  2. cd jest-bug-example && npm install && npx jest Notice the test passes.
  3. Now go to the package.json and raise either the version of jest to 25.0.0 or the version of @jest-runner/electron to 3.0.0
  4. rm -rf node_modules/ && npm install && npx jest

Expected behavior: The test still passes.

Actual behavior: The test fails. The mock is undefined.

    ✕ electron mock (9 ms)

  ● Strip › electron mock

    expect(received).toBeDefined()

    Received: undefined

       5 | describe("Strip", () => {
       6 |   test("electron mock", () => {
    >  7 |     expect(app).toBeDefined();
         |                 ^
       8 |   });
       9 | });
      10 | 

      at Object.<anonymous> (src/main/strip.test.ts:7:17)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        6.846 s