Skip to content

Commit 713746d

Browse files
committed
update tests for cli metadata
1 parent 4b0739c commit 713746d

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

build-reporter-plugin.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ class BugsnagBuildReporterPlugin {
6262
const optionalOpts = {
6363
autoAssignRelease: opts.build.autoAssignRelease,
6464
builderName: opts.build.builderName,
65-
metadata: '{' +
66-
Object.entries(opts.build.metadata)
67-
.map(([key, value]) => `${key}=${value}`)
68-
.join(',') +
69-
'}',
65+
metadata: Object.entries(opts.build.metadata)
66+
.map(([key, value]) => `${key}=${value}`)
67+
.join(','),
7068
provider: opts.build.sourceControl.provider,
7169
repository: opts.build.sourceControl.repository,
7270
revision: opts.build.sourceControl.revision,

test/build-reporter-plugin.test.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test('BugsnagBuildReporterPlugin', t => {
2121
})
2222

2323
test('it sends upon successful build', t => {
24-
t.plan(3)
24+
t.plan(4)
2525
const server = createServer((req, res) => {
2626
let body = ''
2727
req.on('data', (d) => { body += d })
@@ -37,6 +37,7 @@ test('it sends upon successful build', t => {
3737
t.ok(j, 'json body was received')
3838
t.equal(j.appVersion, '1.2.3', 'body should contain app version')
3939
t.equal(j.apiKey, 'YOUR_API_KEY', 'body should contain api key')
40+
t.same(j.metadata, { foo: 'bar', baz: 'qux' }, 'body should contain correct metadata')
4041
})
4142
})
4243
server.listen()

test/fixtures/a/webpack.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ module.exports = {
1010
new BugsnagBuildReporterPlugin({
1111
apiKey: 'YOUR_API_KEY',
1212
appVersion: '1.2.3',
13-
endpoint: `http://localhost:${process.env.PORT}`
13+
endpoint: `http://localhost:${process.env.PORT}`,
14+
metadata: {
15+
foo: 'bar',
16+
baz: 'qux'
17+
}
1418
})
1519
]
1620
}

0 commit comments

Comments
 (0)