Npm Cypress网页包预处理器的网页包编译错误
我无法运行cypress测试并获得以下错误: 当我跑赛普拉斯跑的时候: 下面给出的是网页编译错误Npm Cypress网页包预处理器的网页包编译错误,npm,webpack,cypress,Npm,Webpack,Cypress,我无法运行cypress测试并获得以下错误: 当我跑赛普拉斯跑的时候: 下面给出的是网页编译错误 Webpack Compilation Error ./cypress/integration/features/Pagination.feature Module not found: Error: Can't resolve 'C:UsersCypressProjectode_modulescypress-cucumber-preprocessorlibesolveStepDefinitio
Webpack Compilation Error
./cypress/integration/features/Pagination.feature
Module not found: Error: Can't resolve
'C:UsersCypressProjectode_modulescypress-cucumber-preprocessorlibesolveStepDefinition' in 'C:\Users\CypressProject\cypress\integration\features'
上述路径中也不包括反斜杠
我的网页包配置文件如下:
module.exports = {
resolve: {
extensions: [".ts", ".js"]
},
node: { fs: "empty", child_process: "empty", readline: "empty" },
module: {
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/],
use: [
{
loader: "ts-loader"
}
]
},
{
test: /\.feature$/,
use: [
{
loader: "cypress-cucumber-preprocessor/loader"
}
]
}
]
}
};
我的插件文件:
const wp = require('@cypress/webpack-preprocessor')
const fs = require('fs-extra')
const path = require('path')
function getConfigurationByFile (file) {
const pathToConfigFile = path.resolve('./cypress/', 'config', `${file}.json`)
return fs.readJson(pathToConfigFile)
}
module.exports = (on,config) => {
const file = process.env.ENV_FILE//config.env.envFile
const options = {
webpackOptions: require("../webpack.config.js")
};
on('file:preprocessor', wp(options))
if(file==null){
return getConfigurationByFile('local');
}
else{
return getConfigurationByFile(file);
}
}
有人想解决吗?您应该在
package.json
中使用
"cypress-cucumber-preprocessor": {
"step_definitions": "path/to/steps_definition"
}
我仍然会遇到这样的问题:./cypress/support/step\u definitions/steps.ts模块构建失败(来自./node\u modules/cypress/index.js):LoaderRunneError:Module'C:\Users\ui\node\u modules\cypress\index.js'不是加载器(必须具有正常或变桨功能)@./cypress/integration/features/TC_170.feature 37:0-157@multi./cypress/integration/features/TC_170.feature