我可以在 Cypress 13 中使用哪个版本的
@badeball/cypress-cucumber-preprocessor
?它甚至兼容吗?我的 cypress.config.ts
文件中遇到类型问题:
import { defineConfig } from 'cypress';
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor';
import createBundler from '@bahmutov/cypress-esbuild-preprocessor';
import { createEsbuildPlugin } from '@badeball/cypress-cucumber-preprocessor/esbuild';
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000/',
screenshotOnRunFailure: true,
specPattern: 'cypress/**/*.feature',
video: false,
viewportHeight: 660,
viewportWidth: 1000,
async setupNodeEvents(on, config) {
await addCucumberPreprocessorPlugin(on, config);
on(
'file:preprocessor',
createBundler({
plugins: [createEsbuildPlugin(config)], //ERROR ON THIS LINE!
}),
);
return config;
},
},
});
错误很长,但表明存在类型不匹配:
cypress.config.ts:20:21 - error TS2322: Type 'import("/Users/.../Documents/.../.../node_modules/@badeball/cypress-cucumber-preprocessor/node_modules/esbuild/lib/main").Plugin' is not assignable to type 'import("/Users/.../Documents/.../.../node_modules/esbuild/lib/main").Plugin'.
Types of property 'setup' are incompatible.
etc etc...
我正在使用以下版本:
"@badeball/cypress-cucumber-preprocessor": "^19.2.0",
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
"cypress": "^13.1.0",
此记录在哪里?
此处给出了您选择配置的最小工作示例https://github.com/badeball/cypress-cucumber-preprocessor/tree/v19.2.0/examples/esbuild-ts.
对于您指定的版本,它可以工作。问题很可能出在
tsconfig.json
,确保这两个选项都存在
{
"compilerOptions": {
"esModuleInterop": true,
"module": "nodenext"
}
}
其他一切都如你所描述的那样。