ava: "Enhancement compilation must be configured in AVA’s Babel options" error with TypeScript.

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! some_package@0.0.1 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

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@jhechtf that’d be amazing!

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 .

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