This repository was archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 752
Revert Jest Runners for linting and upgrade Jest to 23 🎉 #6412
Merged
jasonLaster
merged 1 commit into
firefox-devtools:master
from
wldcordeiro:rollback-jest-runners
May 25, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| const path = require("path"); | ||
| const spawn = require("child_process").spawn; | ||
|
|
||
| const isWindows = /^win/.test(process.platform); | ||
| const prettierCmd = path.resolve( | ||
| __dirname, | ||
| `../node_modules/.bin/${isWindows ? "pretty-quick.cmd" : "pretty-quick"}` | ||
| ); | ||
|
|
||
| const args = [ | ||
| "--trailing-comma=none", | ||
| "--bracket-spacing=true", | ||
| "--write", | ||
| "*.js", | ||
| "*.json", | ||
| "packages/**/src/*.js", | ||
| "src/*.js", | ||
| "src/*/*.js", | ||
| "src/components/**/*.css", | ||
| "src/test/mochitest/*.js", | ||
| "src/test/mochitest/!(examples)/**/*.js" | ||
| ]; | ||
|
|
||
| const prettierArgs = process.argv.slice(2).concat(args); | ||
|
|
||
| const prettierProc = spawn(prettierCmd, prettierArgs); | ||
|
|
||
| prettierProc.stdout.on("data", data => console.log(`${data}`)); | ||
| prettierProc.stderr.on("data", data => console.log(`stderr: ${data}`)); | ||
| prettierProc.on("close", code => | ||
| console.log(`prettier ${code === 0 ? "succeeded" : "failed"}`) | ||
| ); | ||
| prettierProc.on("error", error => { | ||
| if (error.code == "ENOENT") { | ||
| console.log(`Hmm, could not find the path ${cmd}.`); | ||
| return; | ||
| } | ||
| console.log(error); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,8 @@ | |
| * [Testing](#testing) | ||
| * [Unit Tests](#unit-tests) | ||
| * [Linting](#linting) | ||
| * [Lint Jest](#lint-jest) | ||
| * [Lint JS](#lint-js) | ||
| * [Lint CSS](#lint-css) | ||
| * [Performance](#performance) | ||
| * [Colors](#colors) | ||
| * [Configs](#configs) | ||
|
|
@@ -485,8 +486,7 @@ yarn run test:all | |
|
|
||
| #### Unit Tests | ||
|
|
||
| `yarn test` - Run all tests and lints with [jest]. | ||
| `yarn test:js` - Run the unit tests with [jest]. | ||
| `yarn test` - Run tests with [jest]. | ||
|
|
||
| * [matchers][jest-matchers] | ||
| * [mock functions][jest-mock] | ||
|
|
@@ -515,7 +515,7 @@ We shallow render the component and simulate an UI interaction like `click`. | |
|
|
||
| ```js | ||
| it("should call handleClick function", () => { | ||
| const onClick = jest.genMockFunction(); | ||
| const onClick = jest.fn(); | ||
| const wrapper = shallow(new CloseButton({ handleClick: onClick })); | ||
|
|
||
| wrapper.simulate("click"); | ||
|
|
@@ -529,7 +529,7 @@ We shallow render the component to a JSON and save it to a fixture. Subsequent r | |
|
|
||
| ```js | ||
| it("should render a button", () => { | ||
| const onClick = jest.genMockFunction(); | ||
| const onClick = jest.fn(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| const buttonClass = "class"; | ||
| const wrapper = shallow( | ||
| new CloseButton({ | ||
|
|
@@ -580,27 +580,31 @@ index a3b2ba6..cd5a8e7 100644 | |
|
|
||
| ### Linting | ||
|
|
||
| | Type | Command | | ||
| | -------- | -------------------- | | ||
| | all | `yarn run lint` | | ||
| | css | `yarn run lint:jest` | | ||
| | js | `yarn run lint:jest` | | ||
| | markdown | `yarn run lint-md` | | ||
| | Type | Command | | ||
| | -------- | ------------------- | | ||
| | all | `yarn run lint` | | ||
| | css | `yarn run lint:css` | | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We swapped back and forth on using |
||
| | js | `yarn run lint:js` | | ||
| | markdown | `yarn run lint:md` | | ||
|
|
||
| #### Lint Jest | ||
| #### Lint CSS | ||
|
|
||
| We use Jest Runners to do the linting for our JS and CSS. | ||
| We use [Stylelint](http://stylelint.io/) to maintain our CSS styles. The [.stylelintrc](../.stylelintrc) file contains the style definitions, please adhere to those styles when making changes. | ||
|
|
||
| Underlying the Jest Runners | ||
| To test your CSS changes run the command: | ||
|
|
||
| We use [eslint](http://eslint.org/) to maintain our JavaScript styles. The [.eslintrc](../.eslintrc) file contains our style definitions, please adhere to those styles when making changes. | ||
| ```bash | ||
| yarn run lint:css | ||
| ``` | ||
|
|
||
| We use [Stylelint](http://stylelint.io/) to maintain our CSS styles. The [.stylelintrc](../.stylelintrc) file contains the style definitions, please adhere to those styles when making changes. | ||
| #### Lint JS | ||
|
|
||
| We use [eslint](http://eslint.org/) to maintain our JavaScript styles. The [.eslintrc](../.eslintrc) file contains our style definitions, please adhere to those styles when making changes. | ||
|
|
||
| To automatically fix many errors run the command: | ||
|
|
||
| ```bash | ||
| yarn run lint:jest | ||
| yarn run lint:js | ||
| ``` | ||
|
|
||
| #### Lint Markdown | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
genMockFunctionwas removed and was an undocumented API. Removing it from our examples and code.jestjs/jest#6173