Do you want to request a feature or report a bug?
bug
What is the current behavior?
Tests fail to run
If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.
npm install --save better-sqlite3my.test.js with following contentconst Database = require('better-sqlite3');
// Everything below isn't necessary, it'll fail anyways.
const sum = (a, b) => a + b;
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
FAIL tests/random.test.js
โ Test suite failed to run
TypeError: Cannot redefine property: MAX_VALUE
at Function.defineProperty (<anonymous>)
at defineStatic (node_modules/integer/index.js:14:9)
at Object.<anonymous> (node_modules/integer/index.js:7:1)
at Object.<anonymous> (node_modules/better-sqlite3/index.js:3:26)
at Object.<anonymous> (tests/random.test.js:1:107)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:169:7)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.139s
Ran all test suites matching "tests/random.test.js".
What is the expected behavior?
Tests should atleast run
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Linux, jest - ^20.0.4, node v8.1.2, npm - 5.0.3 and no config. Importing that package(and not even using it) is sufficient alone to fail jest to even run tests. Even if you don't define a single test, it still fails with same error, but node is able to execute the file successfully.
Ping.
Ping.
Jest calls integer twice in single VM context, which causes the TypeError you get.
Once in index.js file (exporting Integer).
Once in native V8 call to the module, which Jest doesn't support with its module resolution.
Removing Integer from better-sqlite3 exports fixes the issue. Since integer is standalone package, you should be good removing it (e.g. send them a PR and include it in next major release, because it's an API change).
Wonder how we can make Jest understand V8 calls. @cpojer thoughts?
I just ran into this, and it's unfortunate. I don't really understand the problem. Can you shed some more light on what possible changes need to be done? I'm happy to help contribute.
Most helpful comment
Jest calls
integertwice in single VM context, which causes the TypeError you get.Once in
index.jsfile (exportingInteger).Once in native V8 call to the module, which Jest doesn't support with its module resolution.
Removing
Integerfrombetter-sqlite3exports fixes the issue. Sinceintegeris standalone package, you should be good removing it (e.g. send them a PR and include it in next major release, because it's an API change).Wonder how we can make Jest understand V8 calls. @cpojer thoughts?