我无法运行cypress测试并出现以下错误:
当我跑柏树赛跑时:
下面给出Webpack编译错误
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'
不知何故,反斜线也不包括在上述路径中
我的webpack配置文件是:
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);
}
}
有人有解决的办法吗?
1条答案
按热度按时间pkbketx91#
您应该使用以下命令在
package.json
中设置step_definition
路径