fancy-test
fancy-test copied to clipboard
Use context within stub
Hi there,
Is it possible to use the context inside a stub ? It could be useful for use cases like this
import * as tmp from 'tmp-promise'
import {fancy} from 'fancy-test'
import {expect} from 'chai'
describe('suite', () => {
fancy
.add('tmpDir', () => tmp.dir())
.stub(process, 'cwd', () => ctx.tmpDir.path) //Use the context here
.do(ctx => expect(process.cwd()).to.equal(ctx.tmpDir.path))
.finally(ctx => ctx.tmpDir.cleanup())
.it('use context in stub')
})
Is there any workaround to achieve something like this? Trying to use objects added to ctx to have more control over stubs, and would prefer not to use global state