Closed jamestalmage closed 5 years ago
From https://github.com/sindresorhus/ava/issues/644
@spudly has a start here: https://astexplorer.net/#/Uwl4f415pa
For completeness, here's a list of everything that I think would be needed for a complete mocha codemod: [x] transform it() to test() [x] add t parameter to a ArrowFunctionExpression passed to test() [ ] don't de-sync async functions (the codemod above will mess those up currently) [ ] add t parameter to a FunctionExpression passed to test() [x] transform beforeEach() to test.beforeEach() [x] transform afterEach() to test.afterEach() [x] transform after() to test.after() [x] transform before() to test.before() [ ] remove describe() blocks, prepending their text to each test block's description [ ] intelligently handle nested describe blocks if possible. how do we handle nested describe blocks with their own lifecycle hooks? [ ] if the test body FunctionExpression or ArrowFunctionExpression is async, it should use test.serial instead of test Also, it would be nice to have a separate codemod to transform chai assertions to ava assertions. @spudly - https://github.com/sindresorhus/ava/issues/644#issuecomment-204361166 [ ] Transform tests containing a callback ( it('foo', function (done) { ... }) ) to test.cb(t => ... t.end(); @jfmengels - https://github.com/sindresorhus/ava/issues/644#issuecomment-204593881
For completeness, here's a list of everything that I think would be needed for a complete mocha codemod:
it()
test()
t
ArrowFunctionExpression
FunctionExpression
beforeEach()
test.beforeEach()
afterEach()
test.afterEach()
after()
test.after()
before()
test.before()
describe()
test.serial
test
@spudly - https://github.com/sindresorhus/ava/issues/644#issuecomment-204361166
it('foo', function (done) { ... })
test.cb(t => ... t.end();
@jfmengels - https://github.com/sindresorhus/ava/issues/644#issuecomment-204593881
Ideas for handling lifecycle functions and groups:
From https://github.com/sindresorhus/ava/issues/644
@spudly has a start here: https://astexplorer.net/#/Uwl4f415pa