Skip to content

Commit da1a012

Browse files
authored
Merge pull request #100 from buildkite/upload-tags-option
Introduce `tags` option
2 parents 4bd52cd + be8409e commit da1a012

16 files changed

Lines changed: 68 additions & 28 deletions

e2e/cypress.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ describe('examples/cypress', () => {
6565
expect(json).toHaveProperty("run_env.version")
6666
expect(json).toHaveProperty("run_env.collector", "js-buildkite-test-collector")
6767

68+
expect(json).toHaveProperty("tags", { "hello": "cypress" }) // examples/cypress/cypress.config.js
69+
6870
expect(json).toHaveProperty("data[0].name", 'renders')
6971
expect(json).toHaveProperty("data[0].identifier", '<Component /> renders')
7072
expect(json).toHaveProperty("data[0].location", "cypress/component/Component.cy.jsx") // Cypress does not report test line numbers, otherwise we'd see it here

e2e/jasmine.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ describe('examples/jasmine', () => {
6363
expect(json).toHaveProperty("run_env.version")
6464
expect(json).toHaveProperty("run_env.collector", "js-buildkite-test-collector")
6565

66+
expect(json).toHaveProperty("tags", { "hello": "jasmine" }) // examples/jasmine/spec/example.spec.js
67+
6668
expect(json).toHaveProperty("data[0].name", '1 + 2 to equal 3')
6769
expect(json).toHaveProperty("data[0].location", "spec/example.spec.js:7")
6870
expect(json).toHaveProperty("data[0].file_name", "spec/example.spec.js")

e2e/jest.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ describe('examples/jest', () => {
7070
expect(json).toHaveProperty("run_env.version")
7171
expect(json).toHaveProperty("run_env.collector", "js-buildkite-test-collector")
7272

73+
expect(json).toHaveProperty("tags", { "hello": "jest" }) // examples/jest/jest.config.js
74+
7375
expect(json).toHaveProperty("data[0].scope", '')
7476
expect(json).toHaveProperty("data[0].name", '1 + 2 to equal 3')
7577
expect(json).toHaveProperty("data[0].location", "example.test.js:2")
@@ -121,7 +123,7 @@ describe('examples/jest', () => {
121123

122124
test('it should not throw an error', (done) => {
123125
exec('npm test passed.test.js', { cwd, env }, (error, stdout, stderr) => {
124-
console.log(stdout)
126+
//console.log(stdout)
125127
expect(error).toBeNull()
126128

127129
done()

e2e/mocha.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ describe('examples/mocha', () => {
7070
expect(json).toHaveProperty("run_env.version")
7171
expect(json).toHaveProperty("run_env.collector", "js-buildkite-test-collector")
7272

73+
expect(json).toHaveProperty("tags", {"hello": "mocha"}) // examples/mocha/config.json
74+
7375
expect(json).toHaveProperty("data[0].name", '1 + 2 to equal 3')
7476
expect(json).toHaveProperty("data[0].location", "test.js") // Mocha does not report test line numbers, otherwise we'd see it here
7577
expect(json).toHaveProperty("data[0].file_name", "test.js")

e2e/playwright.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ describe('examples/playwright', () => {
6161
expect(data).toHaveProperty("run_env.version")
6262
expect(data).toHaveProperty("run_env.collector", "js-buildkite-test-collector")
6363

64+
expect(data).toHaveProperty("tags", { "hello": "playwright" }) // examples/playwright/playwright.config.js
65+
6466
expect(data).toHaveProperty("data[0].scope", ' chromium example.spec.js has title')
6567
expect(data).toHaveProperty("data[0].name", 'has title')
6668
expect(data).toHaveProperty("data[0].location", "tests/example.spec.js:3:1")

examples/cypress/cypress.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = defineConfig({
44
reporter: "../../cypress/reporter",
55
reporterOptions: {
66
token_name: "BUILDKITE_ANALYTICS_TOKEN",
7+
tags: { "hello": "cypress" },
78
},
89
component: {
910
devServer: {

examples/jasmine/spec/example.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let axios = require('axios')
22
var BuildkiteReporter = require('buildkite-test-collector/jasmine/reporter');
3-
var buildkiteReporter = new BuildkiteReporter();
3+
var buildkiteReporter = new BuildkiteReporter(undefined, { tags: { hello: "jasmine" }});
44
jasmine.getEnv().addReporter(buildkiteReporter);
55

66
// No scope
@@ -18,4 +18,4 @@ describe('sum', () => {
1818
// Test instrumenting a HTTP request
1919
it('connects to buildkite.com', async () => {
2020
const response = await axios.get('https://buildkite.com/')
21-
})
21+
})

examples/jest/jest.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ const config = {
22
// Send results to Test Analytics
33
reporters: [
44
'default',
5-
'buildkite-test-collector/jest/reporter'
5+
['buildkite-test-collector/jest/reporter', {
6+
tags: { hello: "jest" }
7+
}]
68
],
79

810
// Enable column + line capture for Test Analytics
911
testLocationInResults: true
1012
};
1113

12-
module.exports = config;
14+
module.exports = config;

examples/mocha/config.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"reporterEnabled": "spec, buildkite-test-collector/mocha/reporter"
3-
}
2+
"reporterEnabled": "spec, buildkite-test-collector/mocha/reporter",
3+
"buildkiteTestCollectorMochaReporterReporterOptions": {
4+
"tags": {
5+
"hello": "mocha"
6+
}
7+
}
8+
}

examples/playwright/playwright.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ const { defineConfig, devices } = require('@playwright/test');
55
*/
66
module.exports = defineConfig({
77
testDir: './tests',
8-
reporter: [['line'], ['buildkite-test-collector/playwright/reporter']],
8+
reporter: [
9+
['line'],
10+
['buildkite-test-collector/playwright/reporter', {
11+
tags: { "hello": "playwright" }
12+
}]
13+
],
914
webServer: {
1015
command: 'npm start',
1116
url: 'http://127.0.0.1:18080',

0 commit comments

Comments
 (0)