Skip to content

Commit

Permalink
restore esmock.node.test
Browse files Browse the repository at this point in the history
  • Loading branch information
bumblehead committed Oct 12, 2023
1 parent 4427f0a commit c4c5825
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions tests/tests-node/esmock.node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import assert from 'node:assert/strict'
import esmock from 'esmock'
import sinon from 'sinon'
import esmockCache from '../../src/esmockCache.js'
/*

test('should mock node:process', async () => {
// has direct and in-direct calls to `process.cwd()`
const thingBeingTested = await esmock('../local/usesNodeProcess.js', {}, {
Expand Down Expand Up @@ -536,31 +536,3 @@ test('should mock scoped package, @aws-sdk/client-s3 (deep)', async () => {

assert.strictEqual(scopedClientS3.mocked, 'mock client')
})
*/
test('should use custom resolver', async () => {
const customResolverParent = await esmock(
'../local/customResolverParent.js', {}, {
'form-urlencoded': ({ isMocked: true })
}, {
resolvers: [
(moduleId, parent) => {
const pathParent = new URL(parent).pathname
const pathChild = path.resolve(
pathParent, '../../local/customResolverChild.js')

if (/CUSTOMLOADER$/.test(moduleId)) {
console.log('resolved path', new URL(pathChild, parent).href)
}

return /CUSTOMLOADER$/.test(moduleId)
? new URL(pathChild, parent).href
// ? path.join(path.dirname(parent), '../local/customResolverChild.js')
: null
}
]
})

console.log('child', customResolverParent.child)
assert.ok(customResolverParent.child.isCustomResolverChild)
assert.ok(customResolverParent.child.isMocked)
})

0 comments on commit c4c5825

Please sign in to comment.