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

tsdx lint errors out if you have co-located test files (i.e. no test dir) #342

Closed
pcowgill opened this issue Nov 20, 2019 · 5 comments · Fixed by #344
Closed

tsdx lint errors out if you have co-located test files (i.e. no test dir) #342

pcowgill opened this issue Nov 20, 2019 · 5 comments · Fixed by #344

Comments

@pcowgill
Copy link

pcowgill commented Nov 20, 2019

Current Behavior

Added tsdx to a project where test files are in the same dirs as the files under test like this:

src/
  dir1/
    file1.ts
    file1.test.ts

... and ran npm run lint. This is the error generated:

Error: No files matching 'test' were found.

The linter doesn't finish running because of it.

Desired Behavior

Linter doesn't error out due to this project structure.

Suggested Solution

Since this is a common project configuration to ensure you have a test suite per file, either edit the default configuration to support this setup or add a flag to tsdx create or tsdx lint that supports it.

Who does this impact? Who is this for?

All users, potentially. Specifically, people who have their test files next to their files under test in their dir structure.

Describe alternatives you've considered

  • A tsdx eject command that lets you override these settings (sort of against the spirit of the project, though)
  • Stopping writing tests with this style (but the benefits outweigh the costs)

Additional context

@pcowgill
Copy link
Author

pcowgill commented Nov 20, 2019

Having looked more closely at the lint command, it appears that modifying the lint script in my package to "lint": "tsdx lint src" achieves what I want here. So maybe this issue just can be about documenting that in the main README?

@skvale
Copy link
Contributor

skvale commented Nov 21, 2019

If you look at the output of tsdx lint, it does provide a warning immediately above the error:

No input files specified, defaulting to src test
Error: No files matching 'test' were found.

Do you think that warning should suggest something more verbose?

No inputs were passed to lint, it defaults to run on "src test".
If this doesn't work, you can override the lint command in your package.json scripts like "lint": "tsdx lint src"
Error: No files matching 'test' were found.

@pcowgill
Copy link
Author

Yeah, since the value prop of tsdx is zero config like prettier, create-react-app, etc., I assumed it wouldn’t error out for a pretty common setting, and I assumed I wouldn’t have to edit the scripts in package.json this early on.

So I think it should more gracefully handle this case by default, and if not that, then putting actionable advice on how to fix the error like in the example output you gave above would be great.

This project is very well done - I’m a big fan! Keep up the good work. Hopefully I’ll open a PR or two sometime soon.

@arthurdenner
Copy link
Contributor

@pcowgill, once this PR gets merged, we can change the behavior.

@pcowgill
Copy link
Author

@arthurdenner Perfect, thanks!

@agilgur5 agilgur5 changed the title tsdx lint errors out if you have .test files in the same dirs as the files under test tsdx lint errors out if you have co-located test files Mar 17, 2020
@agilgur5 agilgur5 changed the title tsdx lint errors out if you have co-located test files tsdx lint errors out if you have co-located test files (i.e. no test dir) Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants