jest-codemods icon indicating copy to clipboard operation
jest-codemods copied to clipboard

Ava contexts not transformed

Open elijahdorman opened this issue 7 years ago • 2 comments

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

elijahdorman avatar Dec 13 '17 22:12 elijahdorman

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

skovhus avatar Dec 13 '17 22:12 skovhus

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');
});

jamonholmgren avatar Mar 18 '18 05:03 jamonholmgren