Skip to content

Comments

fix: anchor regexps in Jest transforms for proper JSON handling#513

Merged
jaredpalmer merged 1 commit intojaredpalmer:masterfrom
kyle-johnson:unbreak-json
Feb 26, 2020
Merged

fix: anchor regexps in Jest transforms for proper JSON handling#513
jaredpalmer merged 1 commit intojaredpalmer:masterfrom
kyle-johnson:unbreak-json

Conversation

@kyle-johnson
Copy link
Contributor

Master has a new regexp for Jest which breaks tests that reference JSON at some point in the dependency chain. This is a fix.

The regexp .(js|jsx) matches .json which means Jest attempts to load JSON files as JS modules. Since they aren't modules, Jest fails.

transform: {
'.(ts|tsx)': require.resolve('ts-jest/dist'),
'.(js|jsx)': require.resolve('babel-jest'), // jest's default
'.(ts|tsx)$': require.resolve('ts-jest/dist'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the $ here just to be consistent!

@kyle-johnson
Copy link
Contributor Author

This may interact with #491

Copy link
Collaborator

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I thought it was non-standard to not have a '\\.js$' but just went with what the TS was. Turns out there are some issues with that! Thanks for fixing this!

#161 (that #491 fixes) existed beforehand (and is an error from ts-jest) so idk if they impact each other

@agilgur5
Copy link
Collaborator

Okkk just double-checked #161 and I believe this fixes it as well (and so #491 is not necessary).

The full absolute path there is /Users/smashercosmo/Documents/projects/tmp-babel-plugin/node_modules/@babel/core/package.json -- notably "projects/" has a "ts" in it

@jaredpalmer
Copy link
Owner

Which should I merge?

@jaredpalmer jaredpalmer merged commit 1b1b9f8 into jaredpalmer:master Feb 26, 2020
@agilgur5
Copy link
Collaborator

@all-contributors please add @kyle-johnson for bug, code

@allcontributors
Copy link
Contributor

@agilgur5

I've put up a pull request to add @kyle-johnson! 🎉

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.

3 participants