在我的类型记录Cypress配置中,我使用的是cypress-fail-fast插件> https://github.com/javierbrea/cypress-fail-fast,但它似乎不起作用。
// cypress.config.ts
import { defineConfig } from 'cypress';
import plugin from './cypress/plugins/index';
export default defineConfig({
projectId: '**',
fixturesFolder: 'cypress/fixtures',
screenshotOnRunFailure: true,
video: true,
videoCompression: 1,
viewportHeight: 1000,
viewportWidth: 1600,
e2e: {
env: {
API_URL: '**',
CYPRESS_PASSWORD: '**',
},
supportFile: 'cypress/support/index.ts',
baseUrl: 'http://localhost:4200',
experimentalInteractiveRunEvents: true,
setupNodeEvents(on, config) {
plugin(on, config);
},
},
});// supprt/index.ts
import './commands';
import './hooks';
import 'cypress-real-events/support';
import 'cypress-file-upload';
import 'cypress-fail-fast/plugin';这就是我如何设置它的方法,但是当一个测试在规范中失败后,它仍然运行每个测试。
发布于 2022-11-16 16:11:30
您缺少将插件添加到e2e节点事件中。
根据医生:
// cypress.config.js
module.exports = {
e2e: {
setupNodeEvents(on, config) {
require("cypress-fail-fast/plugin")(on, config);
return config;
},
specPattern: "cypress/integration/**/*.js",
},
};所以在你的情况下,那就是:
...
e2e: {
env: {
API_URL: '**',
CYPRESS_PASSWORD: '**',
},
supportFile: 'cypress/support/index.ts',
baseUrl: 'http://localhost:4200',
experimentalInteractiveRunEvents: true,
setupNodeEvents(on, config) {
plugin(on, config);
require("cypress-fail-fast/plugin")(on, config);
},
},
...发布于 2022-11-17 09:50:02
@agoff是对的,但还有另一个问题,所以我将在这里解释。
// support/index.ts
...
import 'cypress-fail-fast';我在导入中添加了/plugin,这是不需要的。
我必须在我的cypressFailFast中声明setupNodeEvents。
我声明plugin函数如下:
setupNodeEvents(on, config) {
plugin(on, config);
},这里的plugin指的是:import plugin from './cypress/plugins/index';
我在那份文件中声明:
export default function plugin(on, config) {
cypressFailFast(on, config);
...现在,一切都如预期的那样运作:

https://stackoverflow.com/questions/74461587
复制相似问题