Skip to content

Commit

Permalink
Clean up error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Dec 13, 2021
1 parent 666655f commit 7713a20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions node.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ function pickEnv(config, opts) {
if (opts.throwOnMissing) {
if (name && name !== 'defaults' && !config[name]) {
throw new BrowserslistError(
'Missing config for Browserslist environment `' + name + '`.'
'Missing config for Browserslist environment `' + name + '`'
)
}
}

return config[name] || config.defaults
}

Expand Down
15 changes: 11 additions & 4 deletions test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,27 @@ test('correctly works with not and one-version browsers', () => {

test('throws error on missing env', () => {
throws(
() => browserslist(null, { path: PACKAGE, throwOnMissing: true, env: 'test' }),
"Missing config for Browserslist environment 'test'."
() =>
browserslist(null, { path: PACKAGE, throwOnMissing: true, env: 'test' }),
"Missing config for Browserslist environment 'test'"
)
})

test('does not throw error on missing defaults env', () => {
equal(
browserslist(null, { path: PACKAGE, throwOnMissing: true, env: 'defaults' }), DEFAULTS
browserslist(null, {
path: PACKAGE,
throwOnMissing: true,
env: 'defaults'
}),
DEFAULTS
)
})

test('does not throw error on missing env', () => {
equal(
browserslist(null, { path: PACKAGE, throwOnMissing: false, env: 'test' }), DEFAULTS
browserslist(null, { path: PACKAGE, throwOnMissing: false, env: 'test' }),
DEFAULTS
)
})

Expand Down

0 comments on commit 7713a20

Please sign in to comment.