无法运行小袋鼠.js在 vscode 中开玩笑



我有一个带有jest和typescript的项目。当我运行jest时,测试运行正常。我准备了wallaby.config.js文件:

// wallaby.config.js
export default function () {
return {
autoDetect: true,
trace: true,
files: ['src/**', '!**/*Spec.ts'],
tests: ['__tests__/**/*Spec.ts'],
debug: true,
env: {
type: 'node',
runner: 'node',
},
};
}

当我尝试启动时,我得到:

Failed to initialize wallaby jest. 
Failed to read Jest configuration from '.': m is not defined 

我的packages.json为type="模块";

另外,我的jest.config.js看起来像:

export default {
verbose: true,
testMatch: ['<rootDir>/__tests__/**/*.ts'],
preset: 'ts-jest',
testEnvironment: 'node',
};

正如我在开始时所说的,如果我键入npx jest正确工作。

我想让小袋鼠在我的vscode上工作。

最后我找到了一个解决方法。

首先安装jasmineesm作为dev依赖项。

现在更新wallay.config.js文件:

export default function configure(wallaby) {
return {
trace: true,
files: ['src/**', '!**/*Spec.ts'],
tests: ['__tests__/**/*Spec.ts'],
debug: true,
testFramework: 'jasmine',   //  <- added
env: {
type: 'node',
runner: 'node',
params: {                 // 
runner: `-r esm`,       //  <- added
},                        //
},
};
}

现在一切都好了。我用jest手动运行测试,wallaby用jasmine。这似乎不是最好的方法,但目前有效。

最新更新