-
Notifications
You must be signed in to change notification settings - Fork 492
Syntax-errors in tests fails to compile, but are not picked up by watch #152
Comments
Is this a duplicate of #148 |
It doesn't look like it. This is replicatable with both npm and yarn, and only exists in files that are not referenced by the entry point of the app. |
Yes, webpack should not care about the test (i.e.
to the list of exclusion in the It seems to have something to do with the way the files are named - if |
I think excluding tests might mess with the actual testing though 😛 |
I does not, actually. The
I've just created a fresh project as noted in the docs, which also creates a default test Tested this renaming since it seems that webpack picks up both |
Ah, that might be true. Still, I've had excludes bite my ass, when e.g. using storybook, so I'd prefer to not go that route. Huh, that seems really strange, so it's the *.test.tsx? pattern it picks up on at the start. I looked at the source of this, and it seems to simply fire up webpack with ts-loader, so I'm not quite sure what's going on. Perhaps there are some diagnostic switches we could toggle? tsc has some, but I'm not sure how we'd go about turning them on here. |
Regularly, it would be possible to configure webpack's stats output to provide details about which modules got included and why, but that won't work here due to the way it's configured for CRA. I've just faced an even more curious behavior: I wanted to switch back the test project to raise the error again, so I've renamed |
That's odd. I'd wager that's because of a caching issue or the earlier behaviour was a fluke of some sort - what'ya reckon? |
I'm not sure what happens, actually. Recreated a fresh version of the project - everything worked as mentioned above. Did that a second time - now neither renaming nor any other of the changes mentioned above works, except adding the entry to the This is definitely odd ... weird... and a bit scary. €dit: OK, after testing various ways to exclude the test file manually (e.g. modifying webpack config) the only change that reliably excludes the test files from being picked up was adding the |
Can I get a quick tldr of where this issue is at? @DorianGrey reading your last comment it seems that this is a TS issue? |
Seems like it's an |
That would be curious, since it's not used in this project ;)
@wmonk : From what I've read in the issues linked in my post above (and what was linked from those), it is a TS feature. TS assumes to be responsible for every file in the current project as long as there is no explicit |
Related to @DorianGrey comment: #159 |
This will throw off editor type checking though. For editors which strictly respect If you're happy to eject and keep your tests separate from your source (eg. a separate Unfortunately I don't think this can be achieved without ejecting because you can't configure the |
ts-node supports the I'm in an odd position where TS errors in tests appear in the frontend, and aren't caught when running the test script. |
This issue is really frustrating on a daily basis. It breaks my workflow (don't care about tests typings or linting while I'm working on a source file) and it's even more annoying to have to restart the dev server or save a random source file to force the refresh. Excluding tests files from tsconfig isn't the perfect workaround because tslint will then also ignore them. You have to lint them manually (or in CI to enforce it a bit more). Moreover, loosing consistency of TS support in IDEs such as VSCode as highlited by @gsteacy is indeed a significant downside. Maybe one inelegant solution could be to use a different tsconfig for the dev server. The default Any other suggestion to fix this is welcomed. I don't see this changing with 2.0/webpack 4, is it? |
Is this a bug report?
Bug report
Can you also reproduce the problem with npm 4.x?
I'm running npm 5.3
Same bug on yarn 0.27.5
Environment
npm ls react-scripts-ts
(if you haven’t ejected): 2.6.0node -v
: 8.4 currently, issue is also on 7.x branchnpm -v
: 5.3yarn --version
(if you use Yarn): 0.27.5Then, specify:
Bug report
If you run yarn/npm start with a syntax error in your tests, it crashes and reports a tsc error. However if you then fix the syntax error, an incremental recompilation is not triggered.
I'd expect it to either not error on the tests at all, or also pick up the changes when the tests are changed.
I think perhaps this might have something to do with webpack building a dependency graph, and only compiling files that are referenced by the entry point.
Support for this thesis: The test files are not picked up for recompilation. However if i export something from the test file, and then import it into e.g. app.tsx, the test files are picked up for incremental recompilation, and it's possible to fix the syntax error and continue developing.
The text was updated successfully, but these errors were encountered: