I have a file (example.js) that looks like this and I'd like to test it.
function alpha () {
return 'alpha'
}
function beta () {
return alpha() + ' ' + 'beta'
}
Here's an example of the test for that file:
const test = require('ava')
const {beta} = require('./example')
test(t => {
t.is(beta(), 'alpha beta')
})
I'm interested in having mocking the use of alpha within beta, when beta is defined within example.js. I know things that mock the require call so that dependencies could be mocked, but that's not what I'm looking for.
Aucun commentaire:
Enregistrer un commentaire