Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ava contexts not transformed #97

Open
elijahdorman opened this issue Dec 13, 2017 · 2 comments
Open

Ava contexts not transformed #97

elijahdorman opened this issue Dec 13, 2017 · 2 comments

Comments

@elijahdorman
Copy link

elijahdorman commented Dec 13, 2017

test.beforeEach(t => {
  t.context.fn = () => 'foo';
});

test('will execute foo', t => {
  t.is(t.context.fn(), 'foo');
});

The t.is will be modified, but the t.context will be left in place and cause errors. Perhaps renaming and moving to the file closure would work.

https://github.com/avajs/ava#test-context

@skovhus
Copy link
Owner

skovhus commented Dec 13, 2017

Thanks for reporting this. Let me know if you would like to try to fix it. : )

@jamonholmgren
Copy link

I ran into this issue as well. The easiest fix was to add this at the beginning:

const t = { context: { fn: null } }

test.beforeEach(t => {
  t.context.fn = () => 'foo';
});

test('will execute foo', t => {
  t.is(t.context.fn(), 'foo');
});

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

No branches or pull requests

3 participants