Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Use context within stub #27

Open
b4nst opened this issue May 28, 2019 · 1 comment
Open

Use context within stub #27

b4nst opened this issue May 28, 2019 · 1 comment

Comments

@b4nst
Copy link

b4nst commented May 28, 2019

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')
})
@APTy
Copy link

APTy commented Mar 16, 2023

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants