I'm trying to run some unit tests with TypeScript using ts-node package as described in official ava's TS recipe.
Facing an error:
> node ./node_modules/ava/cli.js
✖ Enhancement compilation must be configured in AVA’s Babel options.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `node ./node_modules/ava/cli.js`
npm ERR! Exit status 1
Node version: 13.6.0
Ava version: 3.0.0
TypeScript version: 3.7.5
OS: Linux Mint 19.1 (Tessa)
Running ava both ways leads to same result:
node ./node_modules/ava/cli.js as locally installed
ava as globally installed.
Must note that with ava v2.4.0 everything works as expected.
Repository to reproduce: https://github.com/meyve/ava_test
Oh that setting is no longer needed. It should be removed from the documentation. I see it in two different places in that file, perhaps it's mentioned elsewhere too.
Try this
$ yarn add -D @ava/babel
$ cat ava.config.js
export default {
babel: {
compileEnhancements: false
},
files: ['./specs/**/*.ts'],
require: ['ts-node/register'],
extensions: ['ts']
};
@iljoo in running your config I get a new error when attempting to run tests.
× Cannot find module '@ava/babel'
Did you install it? yarn add -D @ava/babel
I did, curious why ava doesn't include it on its own though?
Is this mentioned on the install instructions? I didn't see it, and I don't
remember having this issue with earlier versions of ava.
On Tue, Jan 21, 2020, 00:51 Ilia Mikhailov notifications@github.com wrote:
Did you install it? yarn add -D @ava/babel
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/avajs/ava/issues/2376?email_source=notifications&email_token=AB6GLF7MUARQFOAEUNNDOGLQ62ZQDA5CNFSM4KJHIWTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJO6Q4Y#issuecomment-576579699,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AB6GLFZN6E6GDOFK3BNYJ5TQ62ZQDANCNFSM4KJHIWTA
.
I had the same problem after upgrading tov3.0, but it was resolved after installing@ava/babel.
Try this
$ yarn add -D @ava/babel $ cat ava.config.js export default { babel: { compileEnhancements: false }, files: ['./specs/**/*.ts'], require: ['ts-node/register'], extensions: ['ts'] };
To be clear, this is not needed with AVA 3. Babel is disabled by default, so if you want to use TypeScript with ts-node you only need to update the require and extensions configuration.
The documentation is wrong here, which is why this issue is still open. We'd appreciate a PR to update the TypeScript recipe.
Per the release notes if you want to use Babel you need to install @ava/babel. Having this as a separate package means it can grow on its own, and folks who don't need Babel won't have to install the extra dependencies.
I'm currently using ava in a typescript project without babel, which is why
the requirement for babel was so strange to me.
I'm also using ava 3 - should it not need the babel step? Do we just remove
the babel key? What configuration for ava v3 makes typescript work without
babel?
On Tue, Jan 21, 2020, 01:28 Mark Wubben notifications@github.com wrote:
Try this
$ yarn add -D @ava/babel
$ cat ava.config.js
export default {
babel: {
compileEnhancements: false
},
files: ['./specs/*/.ts'],
require: ['ts-node/register'],
extensions: ['ts']
};To be clear, this is not needed with AVA 3. Babel is disabled by
default, so if you want to use TypeScript with ts-node you only need to
update the require and extensions configuration.The documentation is wrong here, which is why this issue is still open.
We'd appreciate a PR to update the TypeScript recipe.
Per the release notes https://github.com/avajs/ava/releases/tag/v3.0.0
if you want to use Babel you need to install @ava/babel. Having this as a
separate package means it can grow on its own, and folks who don't need
Babel won't have to install the extra dependencies.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/avajs/ava/issues/2376?email_source=notifications&email_token=AB6GLF2EV2ZEE3XHDNGDNR3Q6255PA5CNFSM4KJHIWTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJPCBJQ#issuecomment-576594086,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AB6GLF26RV37MD6FCQVMBTLQ6255PANCNFSM4KJHIWTA
.
I'm currently using ava in a typescript project without babel, which is why the requirement for babel was so strange to me. I'm also using ava 3 - should it not need the babel step? Do we just remove the babel key? What configuration for ava v3 makes typescript work without babel?
Again, the documentation is wrong. The compileEnhancements: false configuration needs to be removed. You do not need to configure babel if you're not using it.
I see. I can take this one if no one else will.
@jhechtf that'd be amazing!
I've made clean install of [email protected], removed entirely compileEnhancements and it works now.
@novemberborn thanks for help!
@jhechtf appreciate you took it!
I've made clean install of [email protected], removed entirely
compileEnhancementsand it works now.@novemberborn thanks for help!
@jhechtf appreciate you took it!
Appreciate the work on this. However, I'm still getting this error with v3.14 via Atom on Win10.
Appreciate the work on this. However, I'm still getting this error with v3.14 via Atom on Win10.
@matt-wiese happy to discuss in a separate Discussion. Without more context this looks like a v2 configuration incompatibility, but again let's discuss elsewhere.
Most helpful comment
@jhechtf that'd be amazing!