【问题标题】:How do I properly run my app when doing e2e tests?进行 e2e 测试时如何正确运行我的应用程序?
【发布时间】:2019-03-07 07:53:59
【问题描述】:

我们有一个我们服务的前端应用程序,我们想在 CI 服务器上对其进行 e2e 测试。最好的方法是什么?

整个测试应该在非 gui CI 上运行,只需一条命令即可执行。

我想到的是这样的:

concurrently "npm run serve" "npx cypress run"

但这似乎增加了巨大且不必要的开销。另外,我必须以某种方式确保在实际提供应用程序之前不会执行测试。

【问题讨论】:

    标签: node.js reactjs testing e2e-testing cypress


    【解决方案1】:

    Cypress continuous integration docs 中所述,您可以使用名为wait-on 的npm 包在运行赛​​普拉斯之前等待您的服务器:

    npm run serve & # run this in the background
    wait-on http://localhost:8000 && npm run cypress
    

    【讨论】:

      【解决方案2】:

      不是一个明确的解决方案,只是一些想法。我们正在使用一个 bash 脚本,它可以通过一个命令启动测试。在那个 bash 脚本中,我们有这个:

      
          # environment variables
          export HOME=${PWD}
      
          yarn install
          ./node_modules/.bin/cypress install
          ./node_modules/.bin/cypress verify
      
          ./node_modules/.bin/cypress run ${SMOKETEST}
      

      【讨论】:

        【解决方案3】:

        如何使用endly 自动化所有 e2e 工作流程? e2e 测试运行器。

        启动应用并将测试委托给 cypress 可能如下所示

        @test.yaml

        pipeline:
          test:
            multiAction: true
            startApp:
              async: true
              action: exec:run
              commands:
                - npm run serve
            runTest:
              async: true
              action: exec:run
              commands:
                - wait-on http://localhost:8000 && npm run cypress
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-05-22
          • 2023-01-24
          • 1970-01-01
          • 2019-11-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-12-21
          相关资源
          最近更新 更多