Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions e2e/jest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,23 @@ describe('examples/jest', () => {
done()
})
}, 10000) // 10s timeout

describe('when failuresOnly is true in reporter options', () => {
test('skips uploads for successful tests', (done) => {
exec('jest --config failuresOnly.config.js', { cwd, env }, (error, stdout, stderr) => {
expect(stdout).toMatch(/.*Test Analytics Sending: ({.*})/m);

const jsonMatch = stdout.match(/.*Test Analytics Sending: ({.*})/m)
const json = JSON.parse(jsonMatch[1])["data"]

// Uncomment to view the JSON
// console.log(json)

expect(json.data.length).toBe(1)
expect(json.data[0].result).toBe("failed")

done()
})
}, 10000) // 10s timeout
})
})
12 changes: 12 additions & 0 deletions examples/jest/failuresOnly.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const config = {
// Send results to Test Analytics
reporters: [
'default',
['buildkite-test-collector/jest/reporter', { failuresOnly: true }]
],

// Enable column + line capture for Test Analytics
testLocationInResults: true
};

module.exports = config;
1 change: 1 addition & 0 deletions jest/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class JestBuildkiteAnalyticsReporter {
const prefixedTestPath = this._paths.prefixTestPath(testResult.testFilePath);

testResult.testResults.forEach((result) => {
if (this._options.failuresOnly && result.status !== 'failed') return
let id = uuidv4()
this._testResults.push({
'id': id,
Expand Down