While writing some test suites for some ES6 modules, I discovered that Jest v26.6 runs into errors when trying to do some cyclic imports.
The problem can be reduced to the following:
ClassA.mjs
import {B} from './ClassB.mjs';
class A {
constructor()
{
//...
}
}
ClassB.mjs
import {A} from './ClassA.mjs';
class B extends A {
constructor()
{
super();
// ...
}
}
Cyclic.test.js
import {B} from "./ClassB.mjs";
describe('Cyclic', () => {
test('Cyclic', () => {
// ...
});
});
Jest exits with a "Maximum call stack size exceeded" error message, at different places of its source, depending on the imports of the test.
Are there any solutions to this, any known workarounds?
Thanks in advance.
question from:
https://stackoverflow.com/questions/65920299/maximum-call-stack-size-exceeded-when-running-cyclic-es6-imports-in-jest 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…