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 4223688
Show file tree
Hide file tree
Showing 7 changed files with 289 additions and 4 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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/node_modules
/test-results.xml
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"
}
}
13 changes: 13 additions & 0 deletions test-results.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="0.008" tests="2" failures="0">
<testsuite name="Root Suite" timestamp="2024-08-15T21:37:42" tests="0" time="0.000" failures="0" retries="0">
</testsuite>
<testsuite name="sum" timestamp="2024-08-15T21:37:42" tests="1" file="/Users/siddange/code/buildpulse/buildpulse-examples/buildpulse-example-mocha/test/sum.spec.js" time="0.001" failures="0" retries="0">
<testcase name="sum adds 1 + 2 to equal 3" time="0.000" classname="adds 1 + 2 to equal 3" retries="0" conclusion="success">
</testcase>
</testsuite>
<testsuite name="flaky" timestamp="2024-08-15T21:37:42" tests="1" file="/Users/siddange/code/buildpulse/buildpulse-examples/buildpulse-example-mocha/test/sum.spec.js" time="0.007" failures="0" retries="9">
<testcase name="flaky flaky failure test with retries enabled" time="0.000" classname="flaky failure test with retries enabled" retries="9" conclusion="success">
</testcase>
</testsuite>
</testsuites>
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 4223688

Please sign in to comment.