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

Tests on Windows fail - reasons and ways to fix #7652

Closed
vtenfys opened this issue Aug 26, 2018 · 1 comment · Fixed by #7655 or #38635
Closed

Tests on Windows fail - reasons and ways to fix #7652

vtenfys opened this issue Aug 26, 2018 · 1 comment · Fixed by #7655 or #38635
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@vtenfys
Copy link
Contributor

vtenfys commented Aug 26, 2018

cc @calcsam re: https://github.com/orgs/gatsbyjs/teams/maintainers/discussions/30/comments/7

Tests on Windows are broken due to two specific issues, which only affect a single package (gatsby-codemods). Both of these are technically upstream issues, rather than issues with Gatsby itself.

TL;DR we need to update @babel/core to at least 7.0.0-rc.3 (the hard part) and change one line in a single file.


Global GraphQL transforms (generated by gatsby-codemods/global-graphql-calls) output with the native system line-endings, rather than always using \n. This causes its jscodeshift tests to fail, since unlike Jest's built-in snapshot testing, jscodeshift's fixture tests don't normalise line endings.

To fix this, change the following line in gatsby-codemods/src/global-graphql-calls.js from:

return root.toSource({ quote: `single` })

to:

return root.toSource({ quote: `single`, lineTerminator: `\n` })

...so that the generated files match the snapshots, which use \n endings, rather than \r\n on Windows. Alternatively, to fix the root cause of the issue, a PR could be sent to jscodeshift so that it normalises line endings when performing fixture tests.


Babel's --ignore **/__tests__ option is buggy on Windows with version 7.0.0-beta.52. Basically Babel converts globs to a regex, and then matches all files against this regex - internally this works a bit differently between Babel 7.0.0-beta.52 (which Gatsby is currently using) and 7.0.0-rc.3 (the latest version) - previously Babel used minimatch to do the conversion, but with the latest RC, it's been rewritten so that it does the conversion itself. So basically, to fix this issue we just need to update Babel to at least 7.0.0-rc.3.

Sidenote: the following line in .babel-preset.js needs to be changed to upgrade to Babel 7 rc3:

image

Various other problems occur but these are package-specific, whereas ALL builds will fail without this change.

@vtenfys vtenfys added type: bug An issue or pull request relating to a bug in Gatsby help wanted Issue with a clear description that the community can help with. labels Aug 26, 2018
@vtenfys
Copy link
Contributor Author

vtenfys commented Aug 26, 2018

I'm currently working on upgrading Gatsby to the latest version of Babel (mostly just fixing config options / tests which have changed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
1 participant