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

Upgrade with-jest-typescript example to next 6.0.0 #4543

Conversation

ngauthier
Copy link
Contributor

Hello! I ran into an issue using typescript and jest with next 6.0.0. I was able to work through fixing it and I wanted to share my solution back to next.js, by upgrading the with-jest-typescript example to next 6.0.0.

The steps I followed were:

  1. npx babel-upgrade --write which added babel-core@^7.0.0-bridge.0 to allow jest's babel 6 to play nice with next's babel 7
  2. Remove ts-jest and replace with babel-jest to use babel to transform the typescript code, as is done when the dev and production builds run
  3. Update the babelrc to use commonjs modules in test mode to be compatible with jest

Also, I removed the NODE_ENV=test on the jest task, because jest sets the env to test anyways, and I'm on windows where this code is incorrect. The other option is to use cross-env but I felt it was simpler to just remove the environment override.

To my knowledge, this PR would help on the following issues:

#3663 #4227 #4531 #4528 #4239

Copy link
Member

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

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

Looks great 👍

@timneutkens timneutkens merged commit bbbf7ab into vercel:canary Jun 6, 2018
lependu pushed a commit to lependu/next.js that referenced this pull request Jun 19, 2018
Hello! I ran into an issue using typescript and jest with next 6.0.0. I was able to work through fixing it and I wanted to share my solution back to next.js, by upgrading the with-jest-typescript example to next 6.0.0.

The steps I followed were:

1. `npx babel-upgrade --write` which added babel-core@^7.0.0-bridge.0 to allow jest's babel 6 to play nice with next's babel 7
2. Remove `ts-jest` and replace with `babel-jest` to use babel to transform the typescript code, as is done when the dev and production builds run
3. Update the babelrc to use commonjs modules in test mode to be compatible with jest

Also, I removed the `NODE_ENV=test` on the jest task, because jest sets the env to test anyways, and I'm on windows where this code is incorrect. The other option is to use `cross-env` but I felt it was simpler to just remove the environment override.

To my knowledge, this PR would help on the following issues:

vercel#3663 vercel#4227 vercel#4531 vercel#4528 vercel#4239
@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants