You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
One part of issue #2403 is that when we add file headers and strip comments, it leads to issues between the React library (https://github.com/facebook/react) and Jest. This can be solved by excluding the JavaScript sources, like I proposed in #2406, but it got me thinking about a more general solution.
If we would only update sources to be mutated in the sandbox, and keep the other sources as-is, it may avoid this kind of an issue with some other projects in the future.
Describe the solution you'd like
rework the sandbox setup as follows:
get all source files, like Stryker already does
only match files to mutate with the sandbox patterns
if a file both is in the files-to-mutate list and matches sandbox.fileHeaders pattern, then add the header
if a file both is in the files-to-mutate list and matches sandbox.stripComments pattern, then strip the comments
I tried working on this idea myself. I think this should be pretty straightforward with Injector from typed-inject but do not yet really understand how to work with the typed-inject API.
P.S. After some testing, I think this would not solve the problem with the React library. So this idea may not be worth considering for the near future.
The text was updated successfully, but these errors were encountered:
Hi @brodybits once again. I overlooked this issue, sorry for the late(r) reply.
If we would only update sources to be mutated in the sandbox, and keep the other sources as-is, it may avoid this kind of an issue with some other projects in the future.
Unfortunately, this won't work for the typescript use case, as stated in #2415
For example:
// concat.tsfunctionconcat(a: string,b: string){returna+b;// return type of this function will change because of mutation switching}// __tests__/concat.spec.tsit('should concat',()=>{constactual: string=concat('a','b');expect(actual).eq('ab');});
In this case, __tests__/concat.spec.ts will give a compile error. You would notice it if you're using buildCommand: "tsc -b" or you use jest-ts for example, the test runner that supports type checking.
The solution I came up with is to prefix all javascript-and-friend files in the sandbox with // @ts-nocheck. That way, you'll disable type checking all together (works from TS3.7~ish). The nice thing is that this works for all typescript use cases.
Unfortunately, other // @ts-xxx directives can still interfere with // @ts-nocheck, that's why I've decided to also add the "stripComments" (or "removeComments") preprocessor. It removes all other comments from a file.
Both these preprocessors are on by default, because I thought that removing comments is usually safe to do. But then again... this is JavaScript we're talking about 😉.
think this would not solve the problem with the React library. So this idea may not be worth considering for the near future.
Is your feature request related to a problem? Please describe.
One part of issue #2403 is that when we add file headers and strip comments, it leads to issues between the React library (https://github.com/facebook/react) and Jest. This can be solved by excluding the JavaScript sources, like I proposed in #2406, but it got me thinking about a more general solution.
If we would only update sources to be mutated in the sandbox, and keep the other sources as-is, it may avoid this kind of an issue with some other projects in the future.
Describe the solution you'd like
rework the sandbox setup as follows:
sandbox
patternssandbox.fileHeaders
pattern, then add the headersandbox.stripComments
pattern, then strip the commentsDescribe alternatives you've considered
updated:
**/*.spec.*
and**/*.test.*
, like I proposed in PR cleanup & simplify default sandbox update options #2406**/__tests__/**
,**/tests/**
,**/test/**
,**/spec/**
, like I tried to do in PR improve default sandbox option strings to ignore tests & test directories #2405sandbox
to not update any sources, like I did for React as described in issue Multiple config workarounds needed for dry run to work for React [Stryker 4.0.0-beta] #2403Additional context
I tried working on this idea myself. I think this should be pretty straightforward with Injector from
typed-inject
but do not yet really understand how to work with thetyped-inject
API.P.S. After some testing, I think this would not solve the problem with the React library. So this idea may not be worth considering for the near future.
The text was updated successfully, but these errors were encountered: