首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在码头用灯塔执行赛柏exec命令?

如何在码头用灯塔执行赛柏exec命令?
EN

Stack Overflow用户
提问于 2022-02-16 11:29:15
回答 1查看 364关注 0票数 1

当我试图在docker映像中执行cypress测试用例时,cypress将打开chrome的新窗口并执行以下命令

代码语言:javascript
复制
  cy.exec(`lighthouse https://www.google.com/ --preset desktop --output-path cypress/lighthouse-html-reports/google.html`)

还会打开新的铬窗口。它用非零错误码抛出色色机的误差.得到了这个错误。

代码语言:javascript
复制
<?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(&apos;lighthouse https://www.google.com/ --preset desktop --output-path cypress/lighthouse-html-reports/google.html&apos;)` 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>

EN

回答 1

Stack Overflow用户

发布于 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")

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71141000

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档