-
Notifications
You must be signed in to change notification settings - Fork 5
"SyntaxError: Unexpected token import" with create-react-app-ts #40
Comments
Hmm interesting. How does the discovering of We've had some issues reported on the stryker main repo about jest not loading plugins: Could you take a look and try to add |
Well, react-scripts-ts creates a Jest configuration that holds a So I think I should not only add But when I do that, I get this:
While
|
Ok, could you try |
Well, that doesn't make a big difference. Only notable difference is that this time, it's |
This should be fixed when we implement stryker-mutator/stryker-js#672 So I'll close this issue for now. |
Still no luck... After upgrading to Stryker 0.22.0 (which has
|
could you try out the jest command from your sandbox directory? In this example: /home/circleci/project/.stryker-tmp/sandbox991748 |
A few more observations... When I run When I look at When I run Stryker with debug logging, it spits out the configuration. Here's a funny thing: the Jest configuration doesn't quite look like what I'd expect:
I'd expect a different Jest configuration because See the CI build for detailed logging. |
I finally understand what the problem is. You're normal test setup does not use
This is actually the nodejs wrapper for all modules. |
My
So indeed, it doesn't run Jest directly. The Running
Note that the |
I think the next problem is the typescript code. You mentioned that you had transpiled code in your sandbox. That shouldn't be the case right? As jest is handling the transpiling of typescript in your use case. So you should remove the |
I removed
The sandbox looks different than it used to do. Before, it would contain a But the good news is that Stryker now generates mutants! I'm not sure what it mutated: transpiled JavaScript or (original) TypeScript? I think it would make more sense to have Stryker take care of transpiling TypeScript, so it can also generate the mutants in the TypeScript code? (Logging) |
Well, that didn't change. Stryker should always mutate your source code. That's why you configured the
In that case I would expect you to also transpile using typescript in your regular workflow (instead of letting Jest take care of that) |
After a lot of digging around (thank @nicojs!) I found the root cause: Stryker doesn't invoke the aforementioned I did some prototyping locally to make Stryker invoke that functions, and it seems to work. I'll polish it a bit and submit a PR. |
Polishing in progress... But I had some issues getting the integration test to work. Turned out that I ran into Jest #5401, which can be solved by upgrading Jest. See e.g. this comment, suggesting that it might be caused by having multiple versions of Jest lying around. Indeed, I turned out to have Jest 20.x (from the Runner itself) as well as 22.x (from CRAT). So I'm wondering if it'd be OK if we upgraded Jest to 22.x in the course of this issue? Or maybe we should have a separate issue for it? |
How easy is it to upgrade to a newer jest version as a user? If it's easy, I would prefer we drop support for older jest versions. Else we'll have yet another version-dependant switch in our code. |
Generally speaking, it is rather easy. But when you are a create-react-app user (in whatever flavour), it is not supported to manually upgrade Jest. Instead, you are supposed to take Jest upgrades as they come to you through an upgrade of create-react-app user (in whatever flavour). |
@mthmulders what other flavors are there? I think |
I'm not aware of other flavours. But that is not to say there are none ;-). For this issue, it would make stuff a whole lot easier if we just require Stryker users to be on Jest 22 or higher. Jest versions come out pretty frequently, as do |
I can confirm this no longer happens in version 0.7.0. Thanks a lot for the support 👍 |
Currently trying out Stryker on my Jest + TypeScript React application. Work is on the feature/mutation-testing branch. I've added a work-around for #38, but now I'm facing a new issue.
The configuration seems fine and Stryker attempts its initial test run. Every test suite fails with this message:
I'm using create-react-app-ts, which uses ts-jest under the hood. This hooks into Jest using a preprocessor which invokes
tsc
to transpile the Typescript code to JavaScript first.I've tried the following in
stryker.conf.js
:project: 'default',
project: 'react',
project
at allThe text was updated successfully, but these errors were encountered: