Skip to content

Commit d215084

Browse files
committed
test: add test case for jest collector failuresOnly option
1 parent 6dc034f commit d215084

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

e2e/jest.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,23 @@ describe('examples/jest', () => {
111111
done()
112112
})
113113
}, 10000) // 10s timeout
114+
115+
describe('when failuresOnly is true in reporter options', () => {
116+
test('skips uploads for successful tests', (done) => {
117+
exec('jest --config failuresOnly.config.js', { cwd, env }, (error, stdout, stderr) => {
118+
expect(stdout).toMatch(/.*Test Analytics Sending: ({.*})/m);
119+
120+
const jsonMatch = stdout.match(/.*Test Analytics Sending: ({.*})/m)
121+
const json = JSON.parse(jsonMatch[1])["data"]
122+
123+
// Uncomment to view the JSON
124+
// console.log(json)
125+
126+
expect(json.data.length).toBe(1)
127+
expect(json.data[0].result).toBe("failed")
128+
129+
done()
130+
})
131+
}, 10000) // 10s timeout
132+
})
114133
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const config = {
2+
// Send results to Test Analytics
3+
reporters: [
4+
'default',
5+
['buildkite-test-collector/jest/reporter', { failuresOnly: true }]
6+
],
7+
8+
// Enable column + line capture for Test Analytics
9+
testLocationInResults: true
10+
};
11+
12+
module.exports = config;

0 commit comments

Comments
 (0)