-
Notifications
You must be signed in to change notification settings - Fork 141
Open
Description
sample.js
export {a, b}
function a() {
return b()
}
function b() {
return 'b'
}
want to replace
b()
but preservea()
...
td.test.js
import test from 'ava'
import * as td from 'testdouble'
// import {a} from './sample.js'
let mock
test.beforeEach(async () => {
// unclear how to use second parameter here, is this a potential solution?
// or is the ask not supported and would need to place `a` and `b` in separate files?
//
mock = await td.replaceEsm('./sample.js')
})
test.afterEach(async () => {
td.reset()
})
test('a', (t) => {
td.when(mock.b()).thenResolve('bee')
t.is(mock.a(), 'bee')
})
test('b', (t) => {
td.when(mock.b()).thenReturn('be')
t.is(mock.b(), 'be')
})
Metadata
Metadata
Assignees
Labels
No labels