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

Jest fails on second test file to reach require("ffi") #6389

Closed
havardh opened this issue Jun 4, 2018 · 2 comments
Closed

Jest fails on second test file to reach require("ffi") #6389

havardh opened this issue Jun 4, 2018 · 2 comments

Comments

@havardh
Copy link

havardh commented Jun 4, 2018

🐛 Bug Report

Jest fails when a second test file requires (directly or indirectly) the ffi module. This happens when jest is executed without the --no-cache flag. It happens with and without the --no-cache flag when running with --runInBand.

To Reproduce

Run jest, jest --runInBand or jest --runInBand --no-cache with the following two test files.

Note: When using jest the first execution will success, subsequent ones will fail.

const ffi = require("ffi");
it("m1", () => {});
const ffi = require("ffi");
it("m2", () => {});
$ jest
 PASS  ./m1_tests.js
 FAIL  ./m2_tests.js
  ● Test suite failed to run

    RangeError: Maximum call stack size exceeded

      at debug (node_modules/debug/src/debug.js:1:1)

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        2.743s

The real world test case provided a bit more context that might be helpful. I am not sure why it did not
show up in the reduced example.

 FAIL  test\integration\integration_tests.js
  ● Test suite failed to run
    RangeError: Maximum call stack size exceeded
      
      at debug (node_modules/debug/src/debug.js:65:17)
      at Object.writePointer [as _writePointer] (node_modules/ref/lib/ref.js:746:3)
      at Object.writePointer [as _writePointer] (node_modules/ref/lib/ref.js:747:11)
      at Object.writePointer [as _writePointer] (node_modules/ref/lib/ref.js:747:11)
      ...
      at Object.writePointer [as _writePointer] (node_modules/ref/lib/ref.js:747:11)
Test Suites: 2 failed, 2 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        24.99s
Ran all test suites matching "integration".

Ref: https://ci.appveyor.com/project/havardh/workflow/build/1.0.371#L147

Expected behavior

Passing tests as jest --no-cache provides.

$ jest --no-cache
 PASS  ./m1_tests.js
 PASS  ./m2_tests.js

Test Suites: 2 passed, 2 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        3.332s
Ran all test suites.
Done in 4.41s.

Link to repo

https://github.com/havardh/jest-require-ffi

Envinfo

$ npx envinfo --preset jest
  System:
    OS: Windows 10
    CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Yarn: 1.7.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
@thymikee
Copy link
Collaborator

thymikee commented Jun 4, 2018

This is a known bug, which we don't have a fix for yet, see: #3552. Any help on the topic appreciated.
Closing as a duplicate (feel free to add your case to linked issue).

@thymikee thymikee closed this as completed Jun 4, 2018
havardh added a commit to havardh/workflow that referenced this issue Jun 4, 2018
This change avoids importing the native module ffi in the windows wm package
multiple times, and avoids a bug in jest.

Ref: jestjs/jest#6389
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants