我使用 cypress 進行組件和 e2e 測驗。兩個測驗都在同一個檔案夾中,.test.e2e.js 用于 e2e 測驗,.test.ct.ts 用于組件測驗。當我運行組件測驗時,我只想測驗 .test.ct.ts 檔案并測驗 e2e 只測驗 .test.e2e.ts 檔案。它適用于組件測驗,cypress 僅測驗 .test.ct.ts 檔案,但是當我運行 e2e 測驗時,cypress 也會測驗 .test.ct.ts,這會導致測驗失敗。
{
"baseUrl": "http://localhost:8080/",
"fixturesFolder": "test/cypress/fixtures",
"integrationFolder": "test/cypress/tests/",
"pluginsFile": "test/cypress/plugins/index.ts",
"screenshotsFolder": "test/cypress/screenshots",
"supportFile": "test/cypress/support/index.ts",
"videosFolder": "test/cypress/videos",
"video": false,
"component": {
"componentFolder": "test/cypress/tests/",
"testFiles": ["**/*.test.ct.ts","**/*.test.ct.js"],
"supportFile": "test/cypress/support/component.ts"
}
}
這是我的柏樹組態檔。對于組件測驗,我可以組態檔夾和檔案,我嘗試過集成,但沒有成功。我正在使用賽普拉斯 9.7.0
這是我嘗試過的配置
{
"baseUrl": "http://localhost:8080/",
"fixturesFolder": "test/cypress/fixtures",
"integration": {
"integrationFolder": "test/cypress/tests/",
"testFiles": ["**/*.test.e2e.ts","**/*.test.e2e.js"]
},
"pluginsFile": "test/cypress/plugins/index.ts",
"screenshotsFolder": "test/cypress/screenshots",
"supportFile": "test/cypress/support/index.ts",
"videosFolder": "test/cypress/videos",
"video": false,
"component": {
"componentFolder": "test/cypress/tests/",
"testFiles": ["**/*.test.ct.ts","**/*.test.ct.js"],
"supportFile": "test/cypress/support/component.ts"
}
}
有任何想法嗎?
uj5u.com熱心網友回復:
根據檔案,賽普拉斯配置定義了e2e物件,而不是integration一個。
您可以嘗試e2e:
{
"baseUrl": "http://localhost:8080/",
"fixturesFolder": "test/cypress/fixtures",
"e2e": {
"integrationFolder": "test/cypress/tests/",
"testFiles": ["**/*.test.e2e.ts","**/*.test.e2e.js"]
},
"pluginsFile": "test/cypress/plugins/index.ts",
"screenshotsFolder": "test/cypress/screenshots",
"supportFile": "test/cypress/support/index.ts",
"videosFolder": "test/cypress/videos",
"video": false,
"component": {
"componentFolder": "test/cypress/tests/",
"testFiles": ["**/*.test.ct.ts","**/*.test.ct.js"],
"supportFile": "test/cypress/support/component.ts"
}
}
uj5u.com熱心網友回復:
您可以使用一些選項來制作僅運行 e2e 或組件測驗的腳本cypress run。最簡單的方法是使用該--spec選項并將檔案夾路徑傳遞給您的 e2e 測驗。包.json 檔案
[
"scripts": {
"e2e": "cypress run --spec 'test/cypress/tests/*.test.e2e.js'"
}
]
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/505170.html
