Skip to content

Commit f37386c

Browse files
bjohansebasljharb
andcommitted
fix(tests): update expected error for invalid JSON config
Co-authored-by: Sebastian Beltran <[email protected]> Co-authored-by: Jordan Harband <[email protected]>
1 parent a777be1 commit f37386c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
},
4242
"devDependencies": {
4343
"nock": "^13.0.3",
44+
"semver": "^7.7.1",
4445
"standard": "^16.0.0",
4546
"tap": "^15.0.0",
4647
"tmp": "^0.2.1"

test/config.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ const gitFixture = require('./fixtures/git')
77

88
const wiby = require('..')
99

10+
const semver = require('semver')
11+
const isGTE20 = semver.satisfies(process.versions.node, '>= 20')
12+
const isGTE22 = semver.satisfies(process.versions.node, '>= 22')
13+
1014
const invalidConfigs = {
11-
'fail-bad-json.json': 'Unexpected end of JSON input',
15+
'fail-bad-json.json': isGTE20 ? `${path.resolve(path.join(__dirname, 'fixtures', 'config', 'fail-bad-json.json'))}: Expected ':' after property name in JSON at position 23${isGTE22 ? ' (line 2 column 1)' : ''}"` : 'Unexpected end of JSON input',
1216
'fail-unknown-root-key.json': '"not-allowed" is not allowed',
1317
'fail-unknown-dependent-key.json': '"dependents[0].sub-key-not-allowed" is not allowed',
1418
'fail-dependent-not-url.json': '"dependents[0].repository" must be a valid uri'
@@ -51,7 +55,7 @@ tap.test('config validation', async (tap) => {
5155
tap.test(file, (tap) => {
5256
tap.throws(() => {
5357
wiby.validate({ config: path.join(__dirname, 'fixtures', 'config', file) })
54-
}, { message: expectedError })
58+
}, expectedError)
5559
tap.end()
5660
})
5761
}

0 commit comments

Comments
 (0)