Skip to content

Commit

Permalink
Updated example with 'mocha-junit-reporters-retries'
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhantdange committed Aug 15, 2024
1 parent dbd8987 commit d2a2f08
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- run: npm ci

- run: npm test -- --reporter mocha-multi-reporters --reporter-options configFile=mocha-reporter-config.json
- run: npm test -- --reporter mocha-multi-reporters --reporter-options configFile=mocha-reporter-config.json --retries 5

- name: Upload test results to BuildPulse for flaky test detection
if: '!cancelled()' # Run this step even when the tests fail. Skip if the workflow is cancelled.
Expand Down
2 changes: 1 addition & 1 deletion mocha-reporter-config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"reporterEnabled": "spec, mocha-junit-reporter"
"reporterEnabled": "spec, mocha-junit-reporters-retries"
}
261 changes: 261 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"devDependencies": {
"mocha": "^9.1.1",
"mocha-junit-reporter": "^2.0.0",
"mocha-multi-reporters": "^1.5.1"
"mocha-multi-reporters": "^1.5.1",
"mocha-junit-reporters-retries": "https://github.com/buildpulse/mocha-junit-reporter"
},
"dependencies": {
"xmlbuilder2": "^3.1.1"
}
}
8 changes: 8 additions & 0 deletions test/sum.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ describe('sum', () => {
assert.equal(sum(1, 2), 3);
});
});

describe('flaky', function () {
it('flaky failure test with retries enabled', function () {
const random = Math.random() * 100;
const passes = random > 70;
assert(passes);
});
});

0 comments on commit d2a2f08

Please sign in to comment.