当我试图在docker映像中执行cypress测试用例时,cypress将打开chrome的新窗口并执行以下命令
cy.exec(`lighthouse https://www.google.com/ --preset desktop --output-path cypress/lighthouse-html-reports/google.html`)还会打开新的铬窗口。它用非零错误码抛出色色机的误差.得到了这个错误。
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="0.0000" tests="1" failures="1">
<testsuite name="Root Suite" timestamp="2022-02-16T10:02:46" tests="0" file="cypress/integration/Performance/lighthouse.feature" time="0.0000" failures="0">
</testsuite>
<testsuite name="Performance Testing with Google Lighthouse" timestamp="2022-02-16T10:02:46" tests="1" time="0.0000" failures="1">
<testcase name="Performance Testing with Google Lighthouse Check application performance using Google Lighthouse" time="0.0000" classname="Check application performance using Google Lighthouse">
<failure message="`cy.exec('lighthouse https://www.google.com/ --preset desktop --output-path cypress/lighthouse-html-reports/google.html')` failed because the command exited with a non-zero code.
Pass `{failOnNonZeroExit: false}` to ignore exit code failures.
Information about the failure:
Code: 1
Stderr:
[36;1mLH:ChromeLauncher [0mWaiting for browser. [36m+0ms[0m
[36;1mLH:ChromeLauncher [0mWaiting for browser... [36m+1ms[0m
[36;1mLH:ChromeLauncher [0mWaiting for browser..... [36m+508...
https://on.cypress.io/exec" type="CypressError"><![CDATA[CypressError: `cy.exec('lighthouse https://www.google.com/ --preset desktop --output-path cypress/lighthouse-html-reports/google.html')` failed because the command exited with a non-zero code.
Pass `{failOnNonZeroExit: false}` to ignore exit code failures.
Information about the failure:
Code: 1
Stderr:
[36;1mLH:ChromeLauncher [0mWaiting for browser. [36m+0ms[0m
[36;1mLH:ChromeLauncher [0mWaiting for browser... [36m+1ms[0m
[36;1mLH:ChromeLauncher [0mWaiting for browser..... [36m+508...
https://on.cypress.io/exec
at https://qagrc.kpmgsofy.com/__cypress/runner/cypress_runner.js:156418:85
at tryCatcher (https://qagrc.kpmgsofy.com/__cypress/runner/cypress_runner.js:13196:23)
at Promise._settlePromiseFromHandler (https://qagrc.kpmgsofy.com/__cypress/runner/cypress_runner.js:11131:31)
at Promise._settlePromise (https://qagrc.kpmgsofy.com/__cypress/runner/cypress_runner.js:11188:18)
at Promise._settlePromise0 (https://qagrc.kpmgsofy.com/__cypress/runner/cypress_runner.js:11233:10)
at Promise._settlePromises (https://qagrc.kpmgsofy.com/__cypress/runner/cypress_runner.js:11313:18)
at _drainQueueStep (https://qagrc.kpmgsofy.com/__cypress/runner/cypress_runner.js:7903:12)
at _drainQueue (https://qagrc.kpmgsofy.com/__cypress/runner/cypress_runner.js:7896:9)
at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (https://qagrc.kpmgsofy.com/__cypress/runner/cypress_runner.js:7912:5)
at Async.drainQueues (https://qagrc.kpmgsofy.com/__cypress/runner/cypress_runner.js:7782:14)
From Your Spec Code:
at Context.eval (https://qagrc.kpmgsofy.com/__cypress/tests?p=cypress/integration/Performance/lighthouse.feature:105:6)
at Context.resolveAndRunStepDefinition (https://qagrc.kpmgsofy.com/__cypress/tests?p=cypress/integration/Performance/lighthouse.feature:10707:29)
at Context.eval (https://qagrc.kpmgsofy.com/__cypress/tests?p=cypress/integration/Performance/lighthouse.feature:10028:35)]]></failure>
</testcase>
</testsuite>
</testsuites>
发布于 2022-09-02 07:26:04
请补充:
--chrome-flags="--no-sandbox --headless --disable-gpu"服从您的命令:
cy.exec(lighthouse https://www.google.com/ --preset desktop --output-path cypress/lighthouse-html-reports/google.html --chrome-flags="--no-sandbox --headless --disable-gpu")
https://stackoverflow.com/questions/71141000
复制相似问题