-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Update CONTRIBUTING.md to give some context about adding tests #7069
Conversation
f24dab9
to
ff9b005
Compare
Codecov Report
@@ Coverage Diff @@
## master #7069 +/- ##
=======================================
Coverage 66.89% 66.89%
=======================================
Files 251 251
Lines 10488 10488
Branches 4 3 -1
=======================================
Hits 7016 7016
Misses 3471 3471
Partials 1 1 Continue to review full report at Codecov.
|
CONTRIBUTING.md
Outdated
|
||
##### Integration tests | ||
|
||
There will be situations however where the work you have done cannot be tested alone using unit tests. In situations like this, you should write an integration test for your code. The integration tests reside within the `e2e` directory. Within this directory, there is a `__tests__` directory. This is where you will write the integration test itself. The tests within this directory execute jest itself using `runJest.js` and assertions are usually made on one if not all the output of the following `status`, `stdout` and `stderr`. The other sub directories within the `e2e` directory are where you will write the test files that jest will run for your integration tests. Feel free to take a look at any of the tests in the `__tests__` directory within `e2e` to have a better sense of how it is currently being done. |
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.
Maybe add that you can run the integration test to inspect that it behaves like you want by running ../../jest
while inside it. Useful when debugging a failing one as well.
E.g.
$ cd e2e/clear-cache
$ ../../jest
PASS __tests__/clear_cache.test.js
✓ stub (4ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.225s
Ran all test suites.
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.
That's a great idea. Do you mind if I steal that code snippet? :)
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.
go for it!
CONTRIBUTING.md
Outdated
|
||
##### Integration tests | ||
|
||
There will be situations however where the work you have done cannot be tested alone using unit tests. In situations like this, you should write an integration test for your code. The integration tests reside within the `e2e` directory. Within this directory, there is a `__tests__` directory. This is where you will write the integration test itself. The tests within this directory execute jest itself using `runJest.js` and assertions are usually made on one if not all the output of the following `status`, `stdout` and `stderr`. The other sub directories within the `e2e` directory are where you will write the test files that jest will run for your integration tests. Feel free to take a look at any of the tests in the `__tests__` directory within `e2e` to have a better sense of how it is currently being done. |
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.
The other sub directories within the
e2e
directory are where you will write thetestfiles that jest will run for your integration tests
I think the phrase "test files" may be confusing, how about saying they're just "files"?
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 was trying to be more explicit in that regard. However, the more I think about it, the more I agree with your point of view. Whatever jest runs, in this context, are test files by default. :P Let me make the necessary changes.
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.
This is great, thank you so much for tackling this!
I'd like some more eyes on it (especially native speakers), but it LGTM
…to inspect the behavior
CONTRIBUTING.md
Outdated
|
||
```bash | ||
$ cd e2e/clear-cache | ||
$ ../../packages/jest-cli/bin/jest.js |
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.
@SimenB I couldn't achieve your behavior by running ../../jest
within the folder. Possibly an error on my machine? Anyways doesn't ../../jest
just invoke ../../packages/jest-cli/bin/jest.js
?
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.
yeah, that's fine. Maybe do node ../../packages/jest-cli/bin/jest.js
so it's easier for people to understand they can do node --inspect
or use ndb
Thanks! |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
New contributors to jest are self aware that the code that they write needs to be tested. More often than not though, they are confused on how to test the functionality they have just written and where to put the test that they want to write. This pull request adds a small section in the contributing.md to guide them as to how tests are done in this repository.
Test plan
No testing required since it's just a document update. Unless you consider proofreading testing? :)
Edit: Typo