-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Find ava.config.js files outside of project directory #2285
Comments
This is a breaking change, since finding new configuration files could break how AVA is used. We'll have to land this as an experiment until it's ready to go out with the next major version. Of course experiments are controlled through configuration, so let's see if we can add an |
why your proposition is better than using a single ava.config.js in the root of the monorepo and running test from the root folder? in this way, tests may even run faster because ava would handle the concurrency and the parallelism while lerna/yarn-workspaces would.
What do you think? |
One problem is how to find the root. By default, AVA assumes that's the repository containing a This issue proposes we speculatively search parent directories, too, until we find a VCS root, hoping to encounter I think this would work well both for single-package-per-repository projects and multiple-package-per-repository projects. |
A very gentle nudge This continues to plague monorepos. As a massive fan of Ava I continue to push its use where and when I can, but this is always a pain point that I must argue through to gain acceptance. Rollup's plugins monorepo uses Ava and we've been forced to copy the same configuration into 28 separate package.json files. That's only going to continue to grow as the project adopts and creates more official plugins, and the pushback internally to switch to a tool that supports monorepos is starting to increase. I do hope this wasn't perceived as pressure, but the uphill struggle to use this, as a superior tool, is real when it comes to the increasingly popular monorepo setup. |
I think that my comment above can help you. run this command from the root: |
Not sure who you're nudging… there is an solution provided and the issue is labeled
You could use an |
😂 @stavalfi while I'm sure that will help some folks, that's a package-manager-specific solution. So for those who don't use yarn (e.g. pnpm) we run into other issues with that proposal. Namely that Ava doesn't think it can find any files. Now, I'm 99.9% certain that's to do with pnpm and how it manages node_modules, so I didn't report that as an issue, as I don't think it's something Ava should be concerned about. If I can get buy-in at my latest professional stop, I can probably get approval for time on this. If it doesn't go my way, not sure I'll be able to. But thanks for responding all the same. |
@shellscape I had another look at the code to see how accurate the proposed solution still is. Since we now look for three different configuration files, accurately resolving them will take some disk access. And it'd be nice to parallelize that, which requires us to load configuration asynchronously. #2629 should get us there. And then we can make this an experimental feature to make default in AVA 4. |
The resolution logic lives here: Lines 202 to 207 in a2f2614
Adjustments should be made so it can find other candidate configuration files. Then, if they've opted into the |
@novemberborn apologies it took me a bit to circle back to this. the proposed solution looks solid, thank you for working on that. what are the next steps that are needed? |
No worries.
"Making it so", as it were 😄 The |
Is there are reason why I simply want to pass in a config file from my monorepo root. Otherwise, like shellscape said, I need an Is there any workaround? |
This ticket is proposing we change that specifically to support monorepos, I want to get it into the v4 release it's one of the last few tasks left. The challenge that Babel ran into is that folks would leave |
Yeah that's a valid concern. Repo root limit is completely warranted. @vjpr I use symlinks to the root/shared ava config. It's not perfect, but links are relatively easy to manage. For 100s of directories I'd recommend a script to CRUD the links. |
Due to avajs/ava#2285, we cannot automatically include the config file from this project within projects that use near-runner-ava.
* feat: add ava and fix stacktrace issue * Apply suggestions from code review * fix: projects need own ava.config.cjs files Due to avajs/ava#2285, we cannot automatically include the config file from this project within projects that use near-runner-ava. * fix: make `near-runner-ava` an alias for ava * fix: update root's package.json * feat: add bootstrap test * build: add --no-install option to bootstrap Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
nit: |
@lightmare in what sense? |
|
@lightmare thanks, that's good to know! |
Fixes #2285. Find configuration files in parent directories, until a `.git` is encountered. Print a warning when AVA is run with a configuration file that is not next to the `package.json`. This is now allowed when passing `--config`. Update the documentation to reflect these changes. Remove documentation of the experimental "next-gen" feature in AVA 3.
Fixes #2285. Find configuration files in parent directories, until a `.git` is encountered. Print a warning when AVA is run with a configuration file that is not next to the `package.json`. This is now allowed when passing `--config`. Update the documentation to reflect these changes. Remove documentation of the experimental "next-gen" feature in AVA 3.
Fixes #2285. Find configuration files in parent directories, until a `.git` is encountered. Print a warning when AVA is run with a configuration file that is not next to the `package.json`. This is now allowed when passing `--config`. Update the documentation to reflect these changes. Remove documentation of the experimental "next-gen" feature in AVA 3.
* feat: add ava and fix stacktrace issue * Apply suggestions from code review * fix: projects need own ava.config.cjs files Due to avajs/ava#2285, we cannot automatically include the config file from this project within projects that use near-runner-ava. * fix: make `near-runner-ava` an alias for ava * fix: update root's package.json * feat: add bootstrap test * build: add --no-install option to bootstrap Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
To better work with monorepo setups it'd be useful if AVA would find
ava.config.js
files that are outside of the project directory for the package that AVA is running in (the directory containing thepackage.json
file).So when looking for
ava.config.js
, we'll keep looking in parent directories until we find anava.config.js
file. However, we'll stop looking once we find a directory that has a.git
directory in it.We'd support other VCS as well.
This is blocked by #2284.
The text was updated successfully, but these errors were encountered: