-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Unit testing docs produce broken project after following steps #8084
Comments
Hi @RobertWSaunders, I was able to setup unit testing with v2. You can check the repo here. I think the repo you provided is broken because of the incorrect dependencies. The reason behind that being gatsby v1 uses babel @pieh @m-allanson any thoughts on this? |
Hmm this looks like a mistake in Gatsby's docs. The unit testing guide was recently added to the docs for Gatsby v2. It looks like the guide was then copied over to the v1 docs, which unfortunately doesn't work with Gatsby v1. I can get your example project to build by changing the following in your package.json. - "gatsby": "^1.9.277",
- "gatsby-link": "^1.6.46",
- "gatsby-plugin-react-helmet": "^2.0.11",
+ "gatsby": "next",
+ "gatsby-plugin-react-helmet": "next",
+ "react": "^16.5.0",
+ "react-dom": "^16.5.0", Edit: Apologies for the docs confusion, incorrect docs are the worst :( |
I've opened a PR to remove the guide from the v1 docs: #8112 |
Revert "Add Docs about Cypress, react-testing-library and testing of CSS-in-JS (#6708)" This reverts commit 32be1dc. These docs apply to Gatsby v2 specifically. Refs #8084 <!-- Q. Which branch should I use for my pull request? A. Use `master` branch (probably). Q. Which branch if my change is an update to Gatsby v2? A. Definitely use `master` branch :) Q. Which branch if my change is an update to documentation or gatsbyjs.org? A. Use `master` branch. A Gatsby maintainer will copy your changes over to the `v1` branch for you Q. Which branch if my change is a bug fix for Gatsby v1? A. In this case, you should use the `v1` branch Q. Which branch if I'm still not sure? A. Use `master` branch. Ask in the PR if you're not sure and a Gatsby maintainer will be happy to help :) Note: We will only accept bug fixes for Gatsby v1. New features should be added to Gatsby v2. Learn more about contributing: https://www.gatsbyjs.org/docs/how-to-contribute/ -->
Awesome, thanks @m-allanson and @kakadiadarpan! I got it to work using your suggestions. I should really just migrate to v2 but I'm hesitant only because its still in beta! Thanks for the fast reply! 🔥 |
I merged that PR, so I think we're good here :) Thanks for the fix @m-allanson, and thanks for confirming @RobertWSaunders! |
@m-allanson How to set up test cases for gatsby v1? |
Description
I'm looking to use Jest in my project for testing. After following the Unit Testing documentation with a fresh project I get errors when trying to run either
npm run build
ornpm run develop
, i.e. the site will no longer build. I have a feeling that the errors are linked to competing Babel configuration between Jest and Gatsby. Throughout this entire process I can see how having a.babelrc
in the root of the project would be really nice because it would make adding additional configuration easier for other modules requiring Babel configuration, someone mentioned this in another issue.Steps to Reproduce
Create a new Gatsby project and follow the steps here to add Jest to your project, after doing so building the site results in errors. Alternatively I've created a project that does this for you to clone here.
I checked this on both version 1 and version 2 of Gatsby and I get the same result.
Expected Result
The website should be able to be built and Jest tests should be able to be run!
Actual Result
When running
npm run build
I get an error like this:And when running
npm run develop
I get:Environment
The text was updated successfully, but these errors were encountered: