[英]Error: Jest: Got error running globalSetup - /home/pptruser/app/node_modules/jest-environment-puppeteer/setup.js
When running from local, its getting passed.从本地运行时,它会通过。 Below error is thrown when run from docker locally.
从 docker 本地运行时抛出以下错误。 I am in the process of setting up my code for my puppeteer test.
我正在为我的 puppeteer 测试设置我的代码。
I also included here below package.json, jest-puppeteer.config, jest.config files.我还在 package.json、jest-puppeteer.config、jest.config 文件下方包含了这里。 Here I haven't included my tests files.
这里我没有包含我的测试文件。
shall you please someone help?你可以请人帮忙吗? Thanks.
谢谢。
Error: Jest: Got error running globalSetup - /home/pptruser/app/node_modules/jest-environment-puppeteer/setup.js, reason: Could not find expected browser (chrome) locally. Run `npm install` to download the correct Chromium revision (1022525).
at ChromeLauncher.launch (/home/pptruser/app/node_modules/puppeteer/lib/cjs/puppeteer/node/ChromeLauncher.js:70:23)
at async Promise.all (index 0)
at async setup (/home/pptruser/app/node_modules/jest-environment-puppeteer/lib/global.js:37:16)
at async /home/pptruser/app/node_modules/@jest/core/build/runGlobalHook.js:125:13
at async waitForPromiseWithCleanup (/home/pptruser/app/node_modules/@jest/transform/build/ScriptTransformer.js:209:5)
at async runGlobalHook (/home/pptruser/app/node_modules/@jest/core/build/runGlobalHook.js:116:9)
at async runJest (/home/pptruser/app/node_modules/@jest/core/build/runJest.js:369:5)
at async _run10000 (/home/pptruser/app/node_modules/@jest/core/build/cli/index.js:320:7)
at async runCLI (/home/pptruser/app/node_modules/@jest/core/build/cli/index.js:173:3)
at async Object.run (/home/pptruser/app/node_modules/jest-cli/build/cli/index.js:155:37)
jest.config.js: jest.config.js:
module.exports = {
preset: "jest-puppeteer"
notifyMode: "always",
maxWorkers: "50%",
maxConcurrency: 150,
maxWorkers: 1,
bail: 1,
collectCoverage: true,
testRunner: "jest-jasmine2",
timers: "fake",
testTimeout: 9000000,
watchman: false,
};
package.json: package.json:
"devDependencies": {
"@babel/preset-env": "^7.18.2",
"babel-jest": "^27.0.6",
"dotenv": "^16.0.1",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"jest-jasmine2": "^27.2.3",
"jest-puppeteer": "^6.1.0",
"prettier": "2.5.1",
"puppeteer": "^14.1.2"
}
jest-puppeteer.config: jest-puppeteer.config:
module.exports = {
launch: {
headless: true,
slowMo: 0,
defaultViewport: null,
args: ["--window-size=1920,1080",
"--incognito",
"--start-maximized",
"--disable-extensions",
"--no-sandbox",
"--disable-setuid-sandbox",
"--no-first-run",
"--no-zygote"],
setDefaultNavigationTimeout: 8000000,
setDefaultTimeout: 8000000,
},
browserContext: "default",
};
My docker file:我的 docker 文件:
FROM docker-remote.artifactory.oci.oraclecorp.com/oraclelinux:7-slim
COPY --from=odo-docker-signed-local.artifactory.oci.oraclecorp.com/odo/base-image-support:ol7x-1.6 / /
RUN yum-config-manager --add-repo https://artifactory.oci.oraclecorp.com/io-ol7-nodejs16-yum-local/ \
--add-repo https://artifactory.oci.oraclecorp.com/io-ol7-oracle-instant-client-yum-local/ \
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \
ORACLE_NPM=https://artifactory.oci.oraclecorp.com/api/npm/npm-remote/
RUN yum -y update \
&& yum -y install nodejs-16.14.2-1.0.1.el7.x86_64 chromium-102.0.5005.115-1.el7.x86_64
RUN groupadd -r pptruser \
&& useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& mkdir -p /home/pptruser/app \
&& chown -R pptruser:pptruser /home/pptruser
WORKDIR /home/pptruser/app
COPY --chown=pptruser:pptruser . .
CMD ["npm","run-script smoke"]
The way we solved this was to download Chromium https://download-chromium.appspot.com/ and unzip into a specific folder: .\node_modules\puppeteer.local-chromium\win64-722234
我们解决这个问题的方法是下载 Chromium https://download-chromium.appspot.com/并解压缩到特定文件夹:
.\node_modules\puppeteer.local-chromium\win64-722234
Some other answers include specifying the path to your chromium like so:其他一些答案包括指定铬的路径,如下所示:
const launchOptions = {
// other options (headless, args, etc)
executablePath: '/home/jack/repos/my-repo/node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux/chrome'
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.