Skip to content

Add error when running jest directly#12726

Merged
sophiebits merged 1 commit intofacebook:masterfrom
sophiebits:no-direct
May 1, 2018
Merged

Add error when running jest directly#12726
sophiebits merged 1 commit intofacebook:masterfrom
sophiebits:no-direct

Conversation

@sophiebits
Copy link
Copy Markdown
Collaborator

$ jest
 FAIL  scripts/jest/dont-run-jest-directly.js
  ● Test suite failed to run

    Don't run `jest` directly. Run `yarn test` instead.

    > 1 | throw new Error("Don't run `jest` directly. Run `yarn test` instead.");
      2 |

      at Object.<anonymous> (scripts/jest/dont-run-jest-directly.js:1:96)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.866s
Ran all test suites.

Copy link
Copy Markdown
Collaborator

@gaearon gaearon left a comment

Choose a reason for hiding this comment

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

lol thanks

Comment thread package.json
"node": "8.x || 9.x"
},
"jest": {
"testRegex": "/scripts/jest/dont-run-jest-directly\\.js$"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Couldn't figure out any way to run something once before any tests are run, so I settled for making it think there's just one test.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

smart

```
$ jest
 FAIL  scripts/jest/dont-run-jest-directly.js
  ● Test suite failed to run

    Don't run `jest` directly. Run `yarn test` instead.

    > 1 | throw new Error("Don't run `jest` directly. Run `yarn test` instead.");
      2 |

      at Object.<anonymous> (scripts/jest/dont-run-jest-directly.js:1:96)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.866s
Ran all test suites.
```
@sophiebits sophiebits merged commit 2003575 into facebook:master May 1, 2018
@flarnie
Copy link
Copy Markdown
Contributor

flarnie commented May 2, 2018

Thanks for adding this @sophiebits 💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants