-
Notifications
You must be signed in to change notification settings - Fork 15.6k
Javascript Testing Basics: Update jest globals/ESLint setup info #30233
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
base: main
Are you sure you want to change the base?
Conversation
1. Read about the [basic process and the benefits of TDD](https://web.archive.org/web/20211123190134/http://godswillokwara.com/index.php/2016/09/09/the-importance-of-test-driven-development/). | ||
1. Watch at least the first 3 videos of [the Unit Testing in JavaScript video series](https://www.youtube.com/playlist?list=PL0zVEGEvSaeF_zoW9o66wa_UCNE3a7BEr). | ||
1. Follow along to [Jest's Getting Started tutorial](https://jestjs.io/docs/getting-started). For the upcoming testing practice and project, you only need to follow the instructions for installing jest. | ||
1. Follow along to Jest’s Getting Started tutorial. For the upcoming testing practice and project, you only need to follow the instructions for installing Jest. Note that while Jest includes global variables like `test` and `expect`, if you are using ESLint, you'll still want to [import the Jest globals your test file needs](https://jestjs.io/docs/getting-started#using-eslint) so ESLint doesn't complain about them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - I know the below was my original suggestion but on another read, I think some people may wonder where the link to the Getting Started tutorial is, and I don't think we need to link the page twice. What do you think of the below instead?
1. Follow along to Jest’s Getting Started tutorial. For the upcoming testing practice and project, you only need to follow the instructions for installing Jest. Note that while Jest includes global variables like `test` and `expect`, if you are using ESLint, you'll still want to [import the Jest globals your test file needs](https://jestjs.io/docs/getting-started#using-eslint) so ESLint doesn't complain about them. | |
1. Follow along to [Jest's Getting Started tutorial](https://jestjs.io/docs/getting-started) until you reach the "Additional Configuration" section, then read the "Using ESLint" section regarding ESLint and Jest globals like `test` and `expect`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it works to point the reader in the direction of the resource's info, but doesn't explicitly state the Jest globals information, which may leave the reader hanging regarding whether or not to import them, like the original issue was. In my opinion it boils down to how detailed we want to make this and linking to your original comment, having learners go out of scope on their own terms if they wish to do so. Maybe we could sum it up as
Follow along with Jest’s Getting Started tutorial up to the "Additional Configuration" section—only the installation steps are needed for the upcoming testing practice and project. Jest provides global variables like
test
andexpect
, but if you're using ESLint, you'll need to explicitly import these in your test files to prevent linting errors (see the "Using ESLint" section in the same tutorial).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the latter half of your wording. Just mixing in my former half because just saying "the installation steps" isn't actually quite clear enough which sections are included and excluded (e.g. the Babel stuff, which is linked in a later lesson when relevant).
1. Follow along to Jest’s Getting Started tutorial. For the upcoming testing practice and project, you only need to follow the instructions for installing Jest. Note that while Jest includes global variables like `test` and `expect`, if you are using ESLint, you'll still want to [import the Jest globals your test file needs](https://jestjs.io/docs/getting-started#using-eslint) so ESLint doesn't complain about them. | |
1. Follow along to [Jest's Getting Started tutorial](https://jestjs.io/docs/getting-started) until you reach the "Additional Configuration" section. Jest also provides global variables like `test` and `expect`, but if you're using ESLint, you'll need to explicitly import these in your test files to prevent linting errors (see the "Using ESLint" section in the same tutorial). |
Because
This PR adds a short paragraph with information regarding Jest global imports when working with ESLint.
This PR
Issue
Closes #29509
Additional Information
Link to issue discussion
Pull Request Requirements
location of change: brief description of change
format, e.g.Intro to HTML and CSS lesson: Fix link text
Because
section summarizes the reason for this PRThis PR
section has a bullet point list describing the changes in this PRIssue
section