我们编写具有Contentful和Shopify集成的Gatsby.js。我们有赛普拉斯测试,我们正在GitHub Actions上运行。 但是我有错误,例如
1) Test shopify cart
Buying only first product
should open product modal:
AssertionError: Timed out retrying: Expected to find element: `[data-test=product-modal]`, but never found it.
at ensureExistence (http://localhost:8000/__cypress/runner/cypress_runner.js:137673:32)
at Object.ensureElExistence (http://localhost:8000/__cypress/runner/cypress_runner.js:137691:12)
at ensureExistence (http://localhost:8000/__cypress/runner/cypress_runner.js:127867:23)
at onFailFn (http://localhost:8000/__cypress/runner/cypress_runner.js:127905:9)
at tryCatcher (http://localhost:8000/__cypress/runner/cypress_runner.js:9065:23)
at Promise._settlePromiseFromHandler (http://localhost:8000/__cypress/runner/cypress_runner.js:7000:31)
at Promise._settlePromise (http://localhost:8000/__cypress/runner/cypress_runner.js:7057:18)
at Promise._settlePromise0 (http://localhost:8000/__cypress/runner/cypress_runner.js:7102:10)
at Promise._settlePromises (http://localhost:8000/__cypress/runner/cypress_runner.js:7178:18)
at _drainQueueStep (http://localhost:8000/__cypress/runner/cypress_runner.js:3772:12)
at _drainQueue (http://localhost:8000/__cypress/runner/cypress_runner.js:3765:9)
at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:8000/__cypress/runner/cypress_runner.js:3781:5)
at Async.drainQueues (http://localhost:8000/__cypress/runner/cypress_runner.js:3651:14)
开始测试的脚本:
"test:e2e:ci": "start-server-and-test develop http://localhost:8000 cy:run"
"develop": "gatsby develop",
有人有解决此问题的想法吗? 本地机器上的Coz一切正常...
答案 0 :(得分:1)
当CI中存在无法在本地复制的问题时,您应该尝试的第一件事是仔细检查CI环境,并确保它与本地计算机紧密匹配。
对于盖茨比网站,尤其是当使用带有机密信息的插件(例如,您的Shopify凭据)时,常见的问题是没有在CI中正确设置environment variables。
确保您的GitHub存储库已设置正确的机密,并确保将其提供给GitHub操作。看看GitHub的Creating and storing encrypted secrets寻求帮助。
如果确定您的环境变量不是问题,则可以通过将Cypress屏幕截图和视频另存为GitHub Action工件来调试Cypress CI运行。 official Cypress GitHub Action有example,介绍了如何使用GitHub的actions/upload-artifact
进行此操作。