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

Babel parse error on flow syntax #2704

Closed
benadamstyles opened this issue Jan 20, 2021 · 4 comments · Fixed by #2783
Closed

Babel parse error on flow syntax #2704

benadamstyles opened this issue Jan 20, 2021 · 4 comments · Fixed by #2783
Labels
🐛 Bug Something isn't working

Comments

@benadamstyles
Copy link

Summary

I am getting a BABEL_PARSE_ERROR on flow type syntax, and I think it's because stryker is adding instrumentation to the top of my files, which means that the // @flow pragma is no longer at the top of those files, so the babel flow plugin no longer runs against those files.

Stryker config

{
  packageManager: 'yarn',
  reporters: ['html', 'clear-text', 'progress', 'dashboard'],
  testRunner: 'jest',
  coverageAnalysis: 'perTest',
  disableTypeChecks: false,

  sandbox: {
    fileHeaders: {
      // I think this is ignored?
      '**/*.js': '// @flow\n\n',
    },
  }
}

Stryker environment

├─ @stryker-mutator/api@4.3.1
├─ @stryker-mutator/core@4.3.1
│  ├─ @stryker-mutator/api@4.3.1
│  ├─ @stryker-mutator/instrumenter@4.3.1
│  ├─ @stryker-mutator/util@4.3.1
├─ @stryker-mutator/instrumenter@4.3.1
│  ├─ @stryker-mutator/api@4.3.1
│  ├─ @stryker-mutator/util@4.3.1
├─ @stryker-mutator/jest-runner@4.3.1
│  ├─ @stryker-mutator/api@4.3.1
│  ├─ @stryker-mutator/util@4.3.1
├─ @stryker-mutator/util@4.3.1
├─ @jest/core@25.4.0

Your Environment

software version(s)
node 14
npm 6
Operating System macos

Add stryker.log

Will add if it's absolutely necessary

@benadamstyles benadamstyles added the 🐛 Bug Something isn't working label Jan 20, 2021
@benadamstyles
Copy link
Author

I have just confirmed that my suspicion was correct – that this is due to the // @flow pragma no longer being at the top of the file – by adding a function above the pragma in one of my source files and running my jest tests as normal: the same error occurs.

@nicojs
Copy link
Member

nicojs commented Jan 20, 2021

Thanks for bug report and triage! This should be a simple fix.

Could you maybe create a small hello-world-like example that reproduces this issue? We would be happy to add it to our e2e test suite so it won't ever break again.

@nicojs
Copy link
Member

nicojs commented Jan 25, 2021

flow-project.zip

I tried my hand at reproducing this myself, but couldn't. See zip.

Unzip and cd into the directory. Then run

npm i
npm run test # see that normal unit testing works
npm run test:mutation # see that Stryker works

@swist
Copy link
Contributor

swist commented Mar 7, 2021

@nicojs here's a MRE: https://github.com/swist/stryker-flow-bug

Just follow the steps you outlined in your comment :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants