Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
446 views
in Technique[技术] by (71.8m points)

ecmascript 6 - "Maximum call stack size exceeded" when running cyclic ES6 imports in Jest

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...