Skip to content

Commit

Permalink
fix(createtestfromscenario): switch from using Cypress fail event to …
Browse files Browse the repository at this point in the history
…mocha runner fail event

it seems that cypress fail event could have only one listener and in case user has own or other
plugins use it cucumber json will be missing results for failed tests as this event is not emitted

re #459, re#454, re#417, re#348
  • Loading branch information
Oleksandr Shevtsov authored and lgandecki committed Mar 23, 2021
1 parent 9183996 commit 82cec59
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/createTestFromScenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,10 @@ const createTestFromScenarios = (
window.testState = testState;

const failHandler = (err) => {
Cypress.off("fail", failHandler);
testState.onFail(err);
throw err;
};

Cypress.on("fail", failHandler);
Cypress.mocha.getRunner().on("fail", failHandler);
});

allScenarios.forEach((section) => {
Expand Down
7 changes: 7 additions & 0 deletions lib/testHelpers/setupTestFramework.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ window.Cypress = {
on: jest.fn(),
off: jest.fn(),
log: jest.fn(),
mocha: {
getRunner: () => {
return {
on: jest.fn(),
};
},
},
Promise: { each: (iterator, iteree) => iterator.map(iteree) },
};

Expand Down

0 comments on commit 82cec59

Please sign in to comment.