无法使用cypress使用Firestore本地模拟器来测试应用程序

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

我有一个使用vue和firebase / firestore构建的应用程序。我使用firebase模拟器进行本地开发,并试图将我的开发工作流程与cypress集成。但是我在Cypress中收到一个错误,如果我从浏览器访问该应用程序,则不会发生。

Firebase CLI版本是7.9.0,赛普拉斯版本是“ ^ 3.8.0”

我的用于加载所有内容的npm脚本如下:

"start": "firebase emulators:exec --only firestore \"npm run dev:appandtest\"",
"dev:appandtest": "concurrently -n \"app,test\" -c \"bgYellow.black,bgWhite.black\" \"npm:dev:app\" \"npm:dev:test\"",
"dev:app": "webpack-dev-server --config build/webpack.dev.js",
"dev:test": "npx cypress open", 

本地服务器在端口9000上运行,而Firebase仿真器在端口8080上运行。

运行后,如果从正常浏览器访问该应用程序,则此屏幕显示的一切正常。

普通

enter image description here

然后我尝试使用此代码运行基本的赛普拉斯测试

    describe('The Home Page', function () {
      it('successfully loads', function () {
        cy.visit('/');
      });
    });

并且我收到以下错误消息:

    [2019-12-14T15:29:24.725Z]  @firebase/firestore: Firestore (6.6.2): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
    This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

    error.ts:166 Uncaught (in promise) FirebaseError: Failed to get document because the client is offline.
        at new FirestoreError (http://localhost:9000/bundle.js:11739:149)
        at Object.next (http://localhost:9000/bundle.js:16734:8)
        at next (http://localhost:9000/bundle.js:16725:4704)
        at http://localhost:9000/bundle.js:16430:411

我还拍摄了屏幕截图:越野车

enter image description here

我尝试研究答案,但没有能力。感谢您事先提供的帮助。

firebase google-cloud-firestore cypress webapp2 firebase-tools
1个回答
0
投票

这里有同样的问题。在“ --headless”模式下也会发生错误。

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