[英]Puppeteer script with jest is failing with Error: Cannot find module 'P:\jest\bin\jest.js'
I am trying to run a simple puppeteer script with jest.我正在尝试开玩笑地运行一个简单的木偶脚本。 Below is my package.json contents:
下面是我的package.json内容:
{
"name": "jest-puppeteer-project",
"version": "1.0.0",
"description": "Test framework using Jest and Puppeteer",
"main": "index.js",
"scripts": {
"test": "jest --forceExit"
},
"author": "Anil Kumar Cheepuru",
"license": "ISC",
"dependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"babel-jest": "^26.6.3",
"jest": "^26.6.3",
"jest-puppeteer": "^4.4.0",
"puppeteer": "^5.4.1"
}
}
Below is my jest-puppeteer.config.js contents:下面是我的 jest-puppeteer.config.js 内容:
module.exports = {
launch: {
headless: false,
},
browserContext: "default"
};
I have also set preset: "jest-puppeteer" in my jest.config.js file.我还在我的 jest.config.js 文件中设置了preset: "jest-puppeteer" 。
Below is the error I am getting in the console when I am trying to run the script using the command: npm run test以下是我在尝试使用以下命令运行脚本时在控制台中遇到的错误: npm run test
I tried to look for a solution in various sources, but no luck.我试图在各种来源寻找解决方案,但没有运气。 Can anyone please help me with this?
谁能帮我解决这个问题?
If you installed jest locally into your project, then this command:如果你在本地安装了 jest 到你的项目中,那么这个命令:
"scripts": {
"test": "jest --forceExit"
}
won't find your locally installed jest.找不到您本地安装的玩笑。 Try changing it to
./node_modules/.bin/jest --forceExit
:尝试将其更改为
./node_modules/.bin/jest --forceExit
:
"scripts": {
"test": "./node_modules/.bin/jest --forceExit"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.