[英]Dynamic imports in Cypress tests using Typescript: ChunkLoadError: Loading chunk 1 failed
I'm trying to use dynamic imports in my cypress tests, like this const inputModule = await import('../../__tests__/testCases/baseInput');
我正在尝试在我的 cypress 测试中使用动态导入,例如 const
inputModule = await import('../../__tests__/testCases/baseInput');
But I'm getting this error: ChunkLoadError: Loading chunk 1 failed.但我收到此错误:ChunkLoadError:加载块 1 失败。 (missing: http://localhost:3000/__cypress/iframes/integration/1.cases.spec.ts )
(缺失: http://localhost:3000/__cypress/iframes/integration/1.cases.spec.ts )
This is my webpack config:这是我的 webpack 配置:
module.exports = on => {
const options = {
webpackOptions: {
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: { transpileOnly: true },
},
],
},
},
};
on('file:preprocessor', wp(options));
};
And this is my tsconfig.json这是我的 tsconfig.json
{
"extends": "../tsconfig.json",
"include": ["cypress/**/*.ts", "**/*.ts", "**/*.js"],
"exclude": [],
}
I had to add this to my tsconfig.json
:我不得不将此添加到我的
tsconfig.json
:
"compilerOptions": {
"module": "CommonJS",
}
and this to my webpack config这对我的 webpack 配置
output: {
fileName: 'bundle.js',
chunkFileName: '[name].bundle.js',
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.