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

fix(babel-transformer): respect top of the file comments/pragma #2783

Merged

Conversation

swist
Copy link
Contributor

@swist swist commented Mar 7, 2021

This means that the stryker mutator hooks are no longer just
prepended to the beginning of file. Instead we also add the comments
which means things like flow should behave correctly

Fixes #2704

@swist swist force-pushed the bugfix/flow-transpilation-withjest branch from 59cea2f to 804c83e Compare March 7, 2021 23:24
This means that the stryker mutator hooks are no longer just
prepended to the beginning of file. Instead we also add the comments
which means things like flow should behave correctly
@swist swist force-pushed the bugfix/flow-transpilation-withjest branch from 804c83e to c0bfb90 Compare March 7, 2021 23:33
@nicojs
Copy link
Member

nicojs commented Mar 10, 2021

@swist thanks for your work! I had to take a closer look, so I checked out the code and I ended up fixing an issue. hope you don't mind.

The issue: you were mutating (no pun intended) the instrumentationBabelHeader. That means you changed it for all other files as well (as well as any other mutation test runs inside the same nodejs process). This is possible because the babel AST is a mutable AST by default and the instrumentationBabelHeader variable itself wasn't frozen.

I already burned myself a couple of times on this as well, so I've changed this by using the deepFreeze helper method to be sure it will never be mutable again. I've changed your implementation in order to accommodate this change. I also revived the original "should add the global js header on top" test to make sure that scenario still works.

I found out that all tests pass even without the root.innerComments. Any idea what that is all about? Do you agree with removing this?

@nicojs nicojs merged commit ca42276 into stryker-mutator:master Mar 11, 2021
@nicojs
Copy link
Member

nicojs commented Mar 11, 2021

I found out that all tests pass even without the root.innerComments. Any idea what that is all about? Do you agree with removing this?

If not, please open a new issue or a new merge request. I want to create a new release today and wanted to have this in 😎

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 this pull request may close these issues.

Babel parse error on flow syntax
2 participants