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: anchor regexps in Jest transforms for proper JSON handling #513

Merged
merged 1 commit into from
Feb 26, 2020
Merged

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

merged 1 commit into from
Feb 26, 2020

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.

@@ -4,8 +4,8 @@ export function createJestConfig(
) {
const config = {
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