avajs / ava

Node.js test runner that lets you develop with confidence 🚀
MIT License
20.74k stars 1.41k forks source link

Print warning when configuration files are not in the project directory #2284

Closed novemberborn closed 1 year ago

novemberborn commented 4 years ago

As of v2.2.0 AVA supports a --config CLI flag that lets you load a different configuration file. Currently that file is required to be in the same directory as the package.json file. This is because the configuration may contain glob patterns, Babel options, and require paths that are relative. It's hard to know how to correctly resolve those patterns, options and paths.

We also don't have an official way of extending a configuration. The suggestion is to use object spread, like so:

import baseConfig from './ava.config.js'

export default {
  ...baseConfig,
  files: ['./integration-tests/**/*']
}

If the configuration files are in different directories we'll end up with a mix of relative patterns, options and paths.

After discussing in #2185 we've decided to allow configuration files that are not in the same directory as the package.json file, however we'll print a warning when AVA is starting.

The suggested warning is:

Using configuration from ${relate path to configuration file, from project directory}

This should be displayed like the warnings for experimental features: https://github.com/avajs/ava/blob/7a668a63b19efdd1b6658eda404a1e5f06d9aa17/lib/cli.js#L168

novemberborn commented 1 year ago

Looks like this was done in #2879.