Ava: Requirements should be configured in package.json

Created on 28 Nov 2016  Â·  7Comments  Â·  Source: avajs/ava

✖ The --require and -r flags are deprecated. Requirements should be configured in package.json - see documentation.

Is there a particular reason for this?

This pains me:

  • I am less flexible now on how to run ava in my project. Unit tests for frontend/backend may have different requirements.
  • I kept my package.json clean so far. Now i am forced to put ava fluff in there.
  • Configuration does not belong in there in the first place IMO.
  • CLI-flags can be removed all the way now since i am not going to put ava options in 2 different places.

1048 looks like api-bikeshed but there is no technical reasoning.

question

Most helpful comment

Removing flexibility to a static "one config per package.json" seems pointless to me. You could still have both and the "static (pkg) > overwrites (cli)" model seems more reasonable to me.

All 7 comments

CLI-flags can be removed all the way now since i am not going to put ava options in 2 different places.

Yes, that's the motivation. Having it in package.json makes it easier for external tools, like editor plugins, to use the same config.

Removing flexibility to a static "one config per package.json" seems pointless to me. You could still have both and the "static (pkg) > overwrites (cli)" model seems more reasonable to me.

Is there any way to have different requirements for different entry points within the same project with the current configuration model?

2 package.json files as far as i understood.

I'm running into an issue with this decision. While using zeit/micro for a server, which uses async-to-gen, I don't get accurate coverage data when using:

"require": [
  "async-to-gen/register"
]

However, the tests run fine. If I want accurate coverage (from nyc), I have to go to latest node version and remove the require config. However, my build server can not be upgraded to latest yet. I'd like to have ava run tests under a cli switch and keep require out of my config so I can run coverage locally.

@AutoSponge I'd write a little wrapper module that checks the Node.js version and requires async-to-gen/register if it doesn't support async/await.

@novemberborn great idea. This worked for me.

if (!require('is-async-supported')()) {
  require('async-to-gen/register')
}
Was this page helpful?
0 / 5 - 0 ratings