Skip to content
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

Improve file and helper selection #2103

Merged
merged 3 commits into from Apr 28, 2019

Conversation

novemberborn
Copy link
Member

@novemberborn novemberborn commented Apr 22, 2019

I've run out of time today and can't finish this PR:

Here's a quick summary of changes. I can expand on rationale later:

  • Require globs to match files, not directories
  • files and sources must be an array of one or more patterns, not a string
  • Only accept files via the CLI, not globs or directories
  • Upgrade globby
  • At this stage, only test files starting with _ are treated as helpers.
    Helper globs should be made configurable.
  • It's no longer possible to override an exclusion pattern. We may
    reintroduce this at a later stage

Fixes #1228
Fixes #909
Fixes #1418
Fixes #1793
Fixes #1501
Fixes #736
Fixes #1540
Fixes #1288
Fixes #1173
Fixes #2085

@novemberborn
Copy link
Member Author

I can expand on rationale later

I'm thinking it's actually quite confusing that files may match directories. It's easier to understand you need to "specify glob patterns that match test files". Similarly, it's easier to understand that the CLI arguments must be actual file paths rather than glob patterns.

Any helper matched as a test file will still be treated as a helper. For now that's just files starting with an underscore. But before we can ship this as a 2.0 we need to make it possible to specify glob patterns for helper files. These then can be tuned to user's project setup. Any test file that also matches the helper patterns will be considered a helper, not a test file.

If you disable the Babel pipeline, AVA won't need to find helper files, just exclude test files that are helpers.

With this PR, test files are still found based on the configured extensions. It just takes a lot less code.

You can specify solely exclusion patterns, which will be applied together with the default patterns.

Overriding the default exclusion patterns is no longer possible. If this becomes a problem we can introduce a setting to customize the default exclusion patterns.

My plan is to get this working and then ship it as a 2.0 beta.

@novemberborn
Copy link
Member Author

With regards to our ESLint plugin, my idea's to expose ava/eslint-helper which can provide the necessary functionality, without needing to expose the full AVA configuration to the plugin, or re-implement functionality there.

@sindresorhus
Copy link
Member

sindresorhus commented Apr 24, 2019

But before we can ship this as a 2.0 we need to make it possible to specify glob patterns for helper files.

I was hoping for v2 we could drop the concept of helpers (which users generally find surprising and awkward) in favor just transpiling everything.

@novemberborn
Copy link
Member Author

I was hoping for v2 we could drop the concept of helpers (which users generally find surprising and awkward) in favor just transpiling everything.

That's not going to happen in the next say two weeks.

Even then, presumably we need the ability to compile tests differently from sources, and this helper work will still be necessary.

Hopefully with these changes helpers are easier to understand though. It'll be test files that start with an underscore. Everything else will be opt-in.

* Require globs to match files, not directories
* files and sources must be an array of one or more patterns, not a
  string
* Only accept files via the CLI, not globs or directories
* Upgrade globby
* At this stage, only test files starting with _ are treated as helpers.
  Helper globs should be made configurable.
* It's no longer possible to override an exclusion pattern. We may
  reintroduce this at a later stage
@novemberborn novemberborn force-pushed the improve-file-and-helper-selection branch from 1f18539 to 3647321 Compare April 28, 2019 16:00
@novemberborn novemberborn marked this pull request as ready for review April 28, 2019 16:00
@novemberborn novemberborn merged commit 4f4dfc7 into master Apr 28, 2019
@novemberborn novemberborn deleted the improve-file-and-helper-selection branch April 28, 2019 16:00
@sindresorhus
Copy link
Member

Does this solve #1264?

Does it?

@novemberborn
Copy link
Member Author

Does it?

No, it's a Chokidar limitation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment