Skip to content

Commit

Permalink
always re-require the package that we need in the requireWithFailedDe…
Browse files Browse the repository at this point in the history
…pendency function
  • Loading branch information
hildjj committed Feb 10, 2021
1 parent 59f3295 commit a2185fa
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function requireWithFailedDependency(source, dependency, fn) {
}
}
delete require.cache[src]
await fn()
await fn(require(source))
require.cache[src] = old_src
require.cache[dep] = old_dep
}
Expand Down
3 changes: 1 addition & 2 deletions test/constants.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const cases = require('./cases')

test('create', async t => {
await cases.requireWithFailedDependency(
'../lib/constants', 'bignumber.js', () => {
const cnst = require('../lib/constants')
'../lib/constants', 'bignumber.js', (cnst) => {
t.falsy(cnst.BigNumber)
t.falsy(cnst.BN)
})
Expand Down
3 changes: 1 addition & 2 deletions test/utils.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ test('cborValueToString', t => {
})

test('web util', async t => {
cases.requireWithFailedDependency('../lib/utils', 'util', () => {
const utils = require('../lib/utils')
cases.requireWithFailedDependency('../lib/utils', 'util', utils => {
t.falsy(utils.inspect)
})
})

0 comments on commit a2185fa

Please sign in to comment.