-
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
Only exclude helpers
directory when inside a test directory
#909
Comments
I think the current pattern is here to stay. Instead I think we should try to better document the patterns. I think a Also, I think our |
Sounds like you've made up your mind. But for what it's worth, it's not so much better docs on how to structure your project. For me it was the idea of bringing ava in to unit test small chunks of a very large existing project with an established file structure. I like my tests to live side-by-side with the files they are testing and the current Also, by renaming the issue you've made it hard for anyone in the same boat to find this issue in the future. Renaming issues for clarity is fine, but please don't use renaming to change the intent of the issue. |
That's what made me assume it was a documentation issue. I guess it would be possible to provide yet another glob pattern for users to define what constitutes a helper, but we're pretty against adding config options unless there is a strong need for it. Can you fully define your directory structure? |
If it doesn't make sense to relax the exclude rule from Here's an example of where we ran into this problem:
In our case we just renamed |
I'm wondering if we couldn't relax it just a bit, to something like this:
So basically, the This gets complicated though, what if you have renamed your test directory in the options: "ava": {
"files": [
"foo/"
]
} Now This is all doable, I'm just wondering if it's worth it. |
Also, this would be a breaking change for people with a |
Hard for me to offer any input on whether it's worth it or not since I still don't understand what "helpers" are within ava. I prefer to name my tests with an explicit extension so I don't have to worry about where they are within the project (which also avoids the need for the helper exclude). |
Early on, we included every file in |
helpers
directory exclusion
So, to be clear, I'm suggesting we relax the exclude, but not as far as you initially proposed. Rather than just |
While we are at it, should we also relax the |
Makes sense to me to only exclude Less keen on relaxing the |
helpers
directory exclusionhelpers
directory when inside a test directory
@jamestalmage sounds like a good plan. @novemberborn can you explain the original reasoning behind the |
@novemberborn never mind! Just saw James' earlier comment:
|
I just ran into this as well and spent about an hour trying to debug why tests weren't being found until I stumbled upon the little note in the README about files in As @jamestalmage noted, it's preferable to have a test directory structure that mirrors your src directory structure. The problem with the proposed solution is that it's not uncommon to have a Rather than using a name that easily conflicts with common directory structures, why not pick something that will clearly stand out as being an ava helper and also be very unlikely to conflict? Proposal: Always exclude For bonus points, it might be nice to just make this whole thing configurable under an |
That's a really niche scenario, only a portion of our users use We already keep a dependency list of what each test |
I'm a little perplexed. Earlier in this conversation you stated:
The But even if the percentage of users that use the It does appear that there has existed an intent to make excludes customizable as well. |
Because being able to add a helpers directory without touching config is super convenient. In my mind, the fact that your Adding config is always an option if no other solutions can be found, but it is one we avoid until it becomes absolutely necessary. |
I feel like we're talking past each other. Why can't we keep the "super convenient" helpers directory default that you prefer but allow others who prefer different defaults to change it? I'm fine with tools being opinionated when it has a point, but there doesn't seem to be a benefit from being opinionated about the names of directories to exclude. We're talking about a fairly straightforward option to overwrite the default excludes. I'll even happily try to submit the PR myself. |
I'm not opposed to having a way to prevent |
…nside directories called 'helpers', and there is no way around that😩 (avajs/ava#909)
Two years later... 😞 any update on this? I think that exclusion makes more injuries than benefits, I have the same "issue" using helpers folder as utilities for a module. It's quite hardcore to change my whole project structure because the test runner can't accept an override exclusion. I think this is very restrictive, and also It tooks me a while to realize of this inconvenient, even when the documentation explicit those requirements. I asume ava has to be aseptic an unopionated utility. So I'm not totally aggree with this decission. its setup has to be as much simple as it can be. but this config I think do not contribute to much for that motivation. |
Any chance the exclude rule for
helpers
can be relaxed so it only applies to files withintest/helpers
? I just ran into acouldn't find any files to test
error for a test file that definitely existed. Ended up being because it was in ahelpers
dir nested deep within the package I was working on.I wasn't even aware ava had a concept of helpers until I ran into this. Where are they documented?
Here's the related PR #357 and issues #355 #750
Edit: added issue #750
The text was updated successfully, but these errors were encountered: