无法解析 bitbucket-pipeline 中的 404-error.cypress-component-test Vue3

问题描述 投票:0回答:1

应用总结

  • 赛普拉斯 v13.6.3
  • vue v3.1.0

我正在尝试创建一个 CI 环境,在 cypress 中创建组件测试,并在每次将测试推送到 bitbucket 时自动运行测试。

在本地环境下,运行正常,但是当我在bitbucket-pipeline上运行测试时,出现404错误。

该错误发生在API获取数据的过程中。 从API获取数据的过程就是拦截并返回mock数据,如下代码所示。

// test.cy.ts
cy.intercept('GET', '/api/v1/test*',{fixture:'test/test.json' }).as('test') // 
cy.wait('@test')

获取数据的流程如下。

exec fetch(Test.vue)ー>Vuex 操作 ー> 客户端 axios get ー> Vuex 突变 ー>Test.vue 获取数据

# bitbucket-pipeline.yml
    - step:
        name: Test
        image: cypress/base:14.16.0
        caches:
          - node
        script:
          - npm ci
          - npm run test

我尝试使用 Docker 在本地调试管道。 但它工作正常。 https://ja.confluence.atlassian.com/bitbucket/debug-your-pipelines-locally-with-docker-838273569.html

我尝试了下面的脚本。

  • cypress run --browser chrome --headless【→404错误
  • 启动服务器和测试启动http://localhost:8080 cypress run --component
vuejs3 cypress bitbucket-pipelines cypress-component-test-runner cypress-intercept
1个回答
0
投票

您得到答案了吗? 如果对你有用的话,你能帮我在 docker 上运行 cypress 组件测试吗?

© www.soinside.com 2019 - 2024. All rights reserved.