我在使用testing-library和cypress運行反應應用程式的測驗時遇到錯誤。在單元測驗和 e2e chrome 上運行的測驗很好,直到它在 e2e firefox 上運行。
我以前沒有使用過firefox,我從這里安裝了firefox來按需運行測驗,但它似乎不起作用。我嘗試在互聯網上搜索錯誤,但找不到任何類似的文章。
歡迎任何有關如何解決此問題的想法。謝謝大家的閱讀。
版本
"react": "^18.1.0",
"cypress": "^10.0.2",
"@cypress/react": "^5.12.5",
"@cypress/webpack-dev-server": "^1.8.4",
配置包.json
"scripts": {
...
"test:all": "react-scripts test --transformIgnorePatterns \"node_modules/(?!@mui)/\" --watchAll=false && npm run test:e2e:all",
"test:unit": "react-scripts test --transformIgnorePatterns \"node_modules/(?!@mui)/\"",
"test:e2e:all": "npm run test:e2e:chrome && npm run test:e2e:firefox && npm run test:e2e:edge && npm run test:e2e:tablet",
"test:e2e:chrome": "npx cypress run --headless --browser chrome",
"test:e2e:firefox": "npx cypress run --headless --browser firefox",
"test:e2e:edge": "npx cypress run --headless --browser edge",
"test:e2e:tablet": "npx cypress run --headless --browser chrome --config viewportWidth=800"
},
來自終端的完整日志:
PS E:\react-todolist-recoil> yarn test:all
yarn run v1.22.4
$ react-scripts test --transformIgnorePatterns "node_modules/(?!@mui)/" --watchAll=false && npm run test:e2e:all
PASS src/pages/Fetch/fetch.test.tsx (6.236 s)
PASS src/pages/Home/home.test.tsx (15.773 s)
Test Suites: 2 passed, 2 total
Tests: 17 passed, 17 total
Snapshots: 0 total
Time: 17.798 s, estimated 18 s
Ran all test suites.
> react-todolist-recoil@0.1.0 test:e2e:all
> npm run test:e2e:chrome && npm run test:e2e:firefox && npm run test:e2e:edge && npm run test:e2e:tablet
> react-todolist-recoil@0.1.0 test:e2e:chrome
> npx cypress run --headless --browser chrome
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 10.0.2 │
│ Browser: Chrome 102 (headless) │
│ Node Version: v16.15.0 (C:\Program Files\nodejs\node.exe) │
│ Specs: 2 found (home.cy.ts, login.cy.ts) │
│ Searched: cypress/e2e/**/*.cy.{js,jsx,ts,tsx} │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: home.cy.ts (1 of 2)
HomePage tests
√ truy c?p, hi?n th? các component quan tr?ng (1949ms)
√ home_toolbar: tiêu ?? và các button (613ms)
√ home_toolbar: disable m?t s? button khi kh?ng có d? li?u (523ms)
√ home_toolbar: flow add d? li?u (915ms)
√ home_toolbar: flow import d? li?u t? file xlsx (623ms)
√ home_toolbar: flow xóa toàn b? d? li?u (523ms)
√ home_table: table row và các action button (492ms)
√ home_table: flow ?ánh d?u todo là ?? hoàn thành (507ms)
√ home_table: flow c?p nh?t m?t table_row (todo) (1107ms)
√ home_table: flow xóa m?t table_row (todo) (602ms)
√ home_pagination: hi?n th? d? li?u gi?i h?n (1412ms)
√ home_pagination: hi?n th? d? li?u theo trang (947ms)
12 passing (10s)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 12 │
│ Passing: 12 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 10 seconds │
│ Spec Ran: home.cy.ts │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: E:\react-todolist-recoil\cypress\videos\home.cy.ts.mp4 (2 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: login.cy.ts (2 of 2)
login.cy.ts
√ should visit (1094ms)
1 passing (1s)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 1 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 1 second │
│ Spec Ran: login.cy.ts │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: E:\react-todolist-recoil\cypress\videos\login.cy.ts.mp4 (0 seconds)
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ √ home.cy.ts 00:10 12 12 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ login.cy.ts 00:01 1 1 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
√ All specs passed! 00:11 13 13 - - -
> react-todolist-recoil@0.1.0 test:e2e:firefox
> npx cypress run --headless --browser firefox
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 10.0.2 │
│ Browser: Firefox 101 (headless) │
│ Node Version: v16.15.0 (C:\Program Files\nodejs\node.exe) │
│ Specs: 2 found (home.cy.ts, login.cy.ts) │
│ Searched: cypress/e2e/**/*.cy.{js,jsx,ts,tsx} │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: home.cy.ts (1 of 2)
Still waiting to connect to Firefox, retrying in 1 second (attempt 18/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 19/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 20/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 21/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 22/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 23/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 24/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 25/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 26/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 27/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 28/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 29/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 30/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 31/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 32/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 33/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 34/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 35/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 36/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 37/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 38/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 39/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 40/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 41/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 42/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 43/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 44/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 45/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 46/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 47/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 48/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 49/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 50/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 51/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 52/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 53/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 54/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 55/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 56/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 57/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 58/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 59/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 60/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 61/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 62/62)
Cypress failed to make a connection to Firefox.
This usually indicates there was a problem opening the Firefox browser.
Error: Could not find url target in browser about:blank. Targets were []
at C:\Users\IVS\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\packages\server\lib\browsers\browser-cri-client.js:90:27
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at retry (C:\Users\IVS\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\packages\server\lib\browsers\browser-cri-client.js:39:20)
at setupRemote (C:\Users\IVS\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\packages\server\lib\browsers\firefox-util.js:109:27)
error Command failed with exit code 1.
uj5u.com熱心網友回復:
在 Windows #22086 上的 Cypress 10.0.2 中有一個未解決的問題"Still waiting to connect to Firefox" issue。
我可以確認我的系統上也發生了同樣的情況。
但是,我可以每晚使用 Firefox
腳本
"test:e2e:firefox": "npx cypress run --headless --browser firefox:nightly",
這些是用于 Firefox 的路徑(在 C:/Program Files 下)
stable: getFirefoxPaths('Mozilla Firefox'),
dev: getFirefoxPaths('Firefox Developer Edition'),
nightly: getFirefoxPaths('Firefox Nightly'),
我有“穩定”(由 指定--browser firefox)和“夜間”(由 指定--browser firefox:nightly),但我不明白為什么“穩定”沒有啟動。它似乎以“每晚”的方式安裝
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/492770.html
