Node 14 + Jest + ESM leads to maximum call stack size error. Before it was unexpected token error. How to fix?

Viewed 643

I have a backend project on Node js. Right now installed Node 14. So I have Jest and want to test functions from the auth.js file. So I create auth.test.js and import login from '../auth.js 0 got unexpected token error.

Then I do the trick with esm according to the node documentation

So I hade "type":module" in my package.json file, but it didn't provide any result. So now I did this:

const esmImport = require('esm')(module);
const login = esmImport('../src/controllers/auth')(module);
test('Auth login', () => {
    let result = 'OK';
    expect(result).toBe('OK')
})

And the error is:


 FAIL  test/auth.test.js
  ● Test suite failed to run

    D:\Programming\Anami\anami-backend\node_modules\wkx\lib\point.js:1
    RangeError: Maximum call stack size exceeded

Any help how to fix this issue?

0 Answers
Related