Skip to content

Commit

Permalink
style: upgrade to prettier 1.9 (#5024)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored and cpojer committed Dec 6, 2017
1 parent 3db5428 commit 0ce82e6
Show file tree
Hide file tree
Showing 21 changed files with 86 additions and 92 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@

### Features

* `[jest-jasmine2]` Update Timeout error message to `jest.timeout` and display current timeout value
([#4990](https://github.com/facebook/jest/pull/4990))
* `[jest-jasmine2]` Update Timeout error message to `jest.timeout` and display
current timeout value ([#4990](https://github.com/facebook/jest/pull/4990))
* `[jest-runner]` Enable experimental detection of leaked contexts
([#4895](https://github.com/facebook/jest/pull/4895))
* `[jest-cli]` Add combined coverage threshold for directories.
Expand Down Expand Up @@ -1048,8 +1048,8 @@ See https://facebook.github.io/jest/blog/2016/12/15/2016-in-jest.html
many tests.
* Add support for property testing via testcheck-js.
* Added a webpack tutorial.
* Added support for virtual mocks through `jest.mock('Module', implementation,
{virtual: true})`.
* Added support for virtual mocks through
`jest.mock('Module', implementation, {virtual: true})`.
* Added snapshot functionality through `toMatchSnapshot()`.
* Redesigned website.

Expand Down
14 changes: 7 additions & 7 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ id: cli
title: Jest CLI Options
---

The `jest` command line runner has a number of useful options. You can run `jest
--help` to view all available options. Many of the options shown below can also
be used together to run tests exactly the way you want. Every one of Jest's
The `jest` command line runner has a number of useful options. You can run
`jest --help` to view all available options. Many of the options shown below can
also be used together to run tests exactly the way you want. Every one of Jest's
[Configuration](Configuration.md) options can also be specified through the CLI.

Here is a brief overview:
Expand Down Expand Up @@ -115,8 +115,8 @@ fail the test and require Jest to be run with `--updateSnapshot`.

Deletes the Jest cache directory and then exits without running tests. Will
delete `cacheDirectory` if the option is passed, or Jest's default cache
directory. The default cache directory can be found by calling `jest
--showConfig`. _Note: clearing the cache will reduce performance._
directory. The default cache directory can be found by calling
`jest --showConfig`. _Note: clearing the cache will reduce performance._

### `--collectCoverageFrom=<glob>`

Expand Down Expand Up @@ -246,8 +246,8 @@ Prevent tests from printing messages through the console.

Alias: `-t`. Run only tests and test suites with a name that matches the regex.
For example, suppose you want to run only tests related to authorization which
will have names like `"GET /api/posts with auth"`, then you can use `jest
-t=auth`.
will have names like `"GET /api/posts with auth"`, then you can use
`jest -t=auth`.

### `--testLocationInResults`

Expand Down
12 changes: 6 additions & 6 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ coverage information will be skipped.
These pattern strings match against the full path. Use the `<rootDir>` string
token to include the path to your project's root directory to prevent it from
accidentally ignoring all of your files in different environments that may have
different root directories. Example: `["<rootDir>/build/",
"<rootDir>/node_modules/"]`.
different root directories. Example:
`["<rootDir>/build/", "<rootDir>/node_modules/"]`.

### `coverageReporters` [array<string>]

Expand Down Expand Up @@ -754,8 +754,8 @@ be skipped.
These pattern strings match against the full path. Use the `<rootDir>` string
token to include the path to your project's root directory to prevent it from
accidentally ignoring all of your files in different environments that may have
different root directories. Example: `["<rootDir>/build/",
"<rootDir>/node_modules/"]`.
different root directories. Example:
`["<rootDir>/build/", "<rootDir>/node_modules/"]`.

### `testRegex` [string]

Expand Down Expand Up @@ -905,8 +905,8 @@ will not be transformed.
These pattern strings match against the full path. Use the `<rootDir>` string
token to include the path to your project's root directory to prevent it from
accidentally ignoring all of your files in different environments that may have
different root directories. Example: `["<rootDir>/bower_components/",
"<rootDir>/node_modules/"]`.
different root directories. Example:
`["<rootDir>/bower_components/", "<rootDir>/node_modules/"]`.

### `unmockedModulePathPatterns` [array<string>]

Expand Down
8 changes: 6 additions & 2 deletions docs/ExpectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ test('resolves to lemon', () => {
});
```

Note that, since you are still testing promises, the test is still asynchronous. Hence, you will need to [tell Jest to wait](TestingAsyncCode.md#promises) by returning the unwrapped assertion.
Note that, since you are still testing promises, the test is still asynchronous.
Hence, you will need to [tell Jest to wait](TestingAsyncCode.md#promises) by
returning the unwrapped assertion.

Alternatively, you can use `async/await` in combination with `.resolves`:

Expand Down Expand Up @@ -424,7 +426,9 @@ test('rejects to octopus', () => {
});
```

Note that, since you are still testing promises, the test is still asynchronous. Hence, you will need to [tell Jest to wait](TestingAsyncCode.md#promises) by returning the unwrapped assertion.
Note that, since you are still testing promises, the test is still asynchronous.
Hence, you will need to [tell Jest to wait](TestingAsyncCode.md#promises) by
returning the unwrapped assertion.

Alternatively, you can use `async/await` in combination with `.rejects`.

Expand Down
4 changes: 2 additions & 2 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ You are now set up to use all ES6 features and React specific syntax.
> `test`. It will not use `development` section like Babel does by default when
> no `NODE_ENV` is set.
> Note: If you've turned off transpilation of ES2015 modules with the option `{
> "modules": false }`, you have to make sure to turn this on in your test
> Note: If you've turned off transpilation of ES2015 modules with the option
> `{ "modules": false }`, you have to make sure to turn this on in your test
> environment.
```json
Expand Down
4 changes: 2 additions & 2 deletions docs/GlobalAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ tests.

### `test.skip(name, fn)`

Also under the aliases: `it.skip(name, fn)` or `xit(name, fn)` or `xtest(name,
fn)`
Also under the aliases: `it.skip(name, fn)` or `xit(name, fn)` or
`xtest(name, fn)`

When you are maintaining a large codebase, you may sometimes find a test that is
temporarily broken for some reason. If you want to skip running this test, but
Expand Down
6 changes: 3 additions & 3 deletions docs/JestObjectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ Creates a mock function similar to `jest.fn` but also tracks calls to

_Note: By default, `jest.spyOn` also calls the **spied** method. This is
different behavior from most other test libraries. If you want to overwrite the
original function, you can use `jest.spyOn(object,
methodName).mockImplementation(() => customImplementation)` or
`object[methodName] = jest.fn(() => customImplementation);`_
original function, you can use
`jest.spyOn(object, methodName).mockImplementation(() => customImplementation)`
or `object[methodName] = jest.fn(() => customImplementation);`_

Example:

Expand Down
5 changes: 3 additions & 2 deletions docs/Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ More information on Node debugging can be found
### Debugging in WebStorm

The easiest way to debug Jest tests in
[WebStorm](https://www.jetbrains.com/webstorm/) is using `Jest run/debug
configuration`. It will launch tests and automatically attach debugger.
[WebStorm](https://www.jetbrains.com/webstorm/) is using
`Jest run/debug configuration`. It will launch tests and automatically attach
debugger.

In the WebStorm menu `Run` select `Edit Configurations...`. Then click `+` and
select `Jest`. Optionally specify the Jest configuration file, additional
Expand Down
4 changes: 2 additions & 2 deletions docs/Webpack.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ Then all your className lookups on the styles object will be returned as-is
```

> Notice that Proxy is enabled in Node 6 by default. If you are not on Node 6
> yet, make sure you invoke Jest using `node --harmony_proxies
> node_modules/.bin/jest`.
> yet, make sure you invoke Jest using
> `node --harmony_proxies node_modules/.bin/jest`.
If `moduleNameMapper` cannot fulfill your requirements, you can use Jest's
[`transform`](Configuration.md#transform-object-string-string) config option to
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"mkdirp": "^0.5.1",
"mocha": "^4.0.1",
"mock-fs": "^4.4.1",
"prettier": "^1.8.2",
"prettier": "^1.9.1",
"progress": "^2.0.0",
"react": "^15.4.2",
"react-addons-test-utils": "15.4.2",
Expand Down Expand Up @@ -148,6 +148,7 @@
},
"prettier": {
"bracketSpacing": false,
"proseWrap": "always",
"singleQuote": true,
"trailingComma": "all"
}
Expand Down
46 changes: 22 additions & 24 deletions packages/expect/src/__tests__/matchers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,7 @@ describe(
jestExpect(big).toBeGreaterThanOrEqual(small);
});

it(`{pass: false} expect(${small}).toBeGreaterThanOrEqual(${
big
})`, () => {
it(`{pass: false} expect(${small}).toBeGreaterThanOrEqual(${big})`, () => {
jestExpect(small).not.toBeGreaterThanOrEqual(big);
});

Expand Down Expand Up @@ -715,9 +713,9 @@ describe('.toMatch()', () => {
describe('.toHaveLength', () => {
[[[1, 2], 2], [[], 0], [['a', 'b'], 2], ['abc', 3], ['', 0]].forEach(
([received, length]) => {
test(`{pass: true} expect(${stringify(received)}).toHaveLength(${
length
})`, () => {
test(`{pass: true} expect(${stringify(
received,
)}).toHaveLength(${length})`, () => {
jestExpect(received).toHaveLength(length);
expect(() =>
jestExpect(received).not.toHaveLength(length),
Expand All @@ -728,9 +726,9 @@ describe('.toHaveLength', () => {

[[[1, 2], 3], [[], 1], [['a', 'b'], 99], ['abc', 66], ['', 1]].forEach(
([received, length]) => {
test(`{pass: false} expect(${stringify(received)}).toHaveLength(${
length
})`, () => {
test(`{pass: false} expect(${stringify(
received,
)}).toHaveLength(${length})`, () => {
jestExpect(received).not.toHaveLength(length);
expect(() =>
jestExpect(received).toHaveLength(length),
Expand Down Expand Up @@ -758,9 +756,9 @@ describe('.toHaveProperty()', () => {
[{a: {b: {c: 5}}}, 'a.b', {c: 5}],
[Object.assign(Object.create(null), {property: 1}), 'property', 1],
].forEach(([obj, keyPath, value]) => {
test(`{pass: true} expect(${stringify(obj)}).toHaveProperty('${
keyPath
}', ${stringify(value)})`, () => {
test(`{pass: true} expect(${stringify(
obj,
)}).toHaveProperty('${keyPath}', ${stringify(value)})`, () => {
jestExpect(obj).toHaveProperty(keyPath, value);
expect(() =>
jestExpect(obj).not.toHaveProperty(keyPath, value),
Expand All @@ -779,9 +777,9 @@ describe('.toHaveProperty()', () => {
['abc', 'a.b.c', {a: 5}],
[{a: {b: {c: 5}}}, 'a.b', {c: 4}],
].forEach(([obj, keyPath, value]) => {
test(`{pass: false} expect(${stringify(obj)}).toHaveProperty('${
keyPath
}', ${stringify(value)})`, () => {
test(`{pass: false} expect(${stringify(
obj,
)}).toHaveProperty('${keyPath}', ${stringify(value)})`, () => {
expect(() =>
jestExpect(obj).toHaveProperty(keyPath, value),
).toThrowErrorMatchingSnapshot();
Expand All @@ -794,9 +792,9 @@ describe('.toHaveProperty()', () => {
[{a: 0}, 'a'],
[{a: {b: undefined}}, 'a.b'],
].forEach(([obj, keyPath]) => {
test(`{pass: true} expect(${stringify(obj)}).toHaveProperty('${
keyPath
}')'`, () => {
test(`{pass: true} expect(${stringify(
obj,
)}).toHaveProperty('${keyPath}')'`, () => {
jestExpect(obj).toHaveProperty(keyPath);
expect(() =>
jestExpect(obj).not.toHaveProperty(keyPath),
Expand All @@ -811,9 +809,9 @@ describe('.toHaveProperty()', () => {
[1, 'a.b.c'],
['abc', 'a.b.c'],
].forEach(([obj, keyPath]) => {
test(`{pass: false} expect(${stringify(obj)}).toHaveProperty('${
keyPath
}')`, () => {
test(`{pass: false} expect(${stringify(
obj,
)}).toHaveProperty('${keyPath}')`, () => {
expect(() =>
jestExpect(obj).toHaveProperty(keyPath),
).toThrowErrorMatchingSnapshot();
Expand All @@ -828,9 +826,9 @@ describe('.toHaveProperty()', () => {
[{a: {b: {}}}, null],
[{a: {b: {}}}, 1],
].forEach(([obj, keyPath]) => {
test(`{error} expect(${stringify(obj)}).toHaveProperty('${
keyPath
}')`, () => {
test(`{error} expect(${stringify(
obj,
)}).toHaveProperty('${keyPath}')`, () => {
expect(() =>
jestExpect(obj).toHaveProperty(keyPath),
).toThrowErrorMatchingSnapshot();
Expand Down
6 changes: 3 additions & 3 deletions packages/expect/src/matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,9 @@ const matchers: MatchersObject = {
` ${printReceived(result.value)}` +
(diffString ? `\n\nDifference:\n\n${diffString}` : '')
: traversedPath
? `Received:\n ${RECEIVED_COLOR('object')}.${
traversedPath
}: ${printReceived(lastTraversedObject)}`
? `Received:\n ${RECEIVED_COLOR(
'object',
)}.${traversedPath}: ${printReceived(lastTraversedObject)}`
: '')
);
};
Expand Down
16 changes: 4 additions & 12 deletions packages/jest-cli/src/lib/watch_plugin_registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export default class WatchPluginRegistry {
// before assuming it's a valid watch plugin.
if (getType(maybePlugin) !== 'object') {
throw new Error(
`Jest watch plugin ${
pluginModulePath
} must be an ES Module or export an object`,
`Jest watch plugin ${pluginModulePath} must be an ES Module or export an object`,
);
}
if (getType(maybePlugin.key) !== 'number') {
Expand All @@ -44,26 +42,20 @@ export default class WatchPluginRegistry {
}
if (getType(maybePlugin.prompt) !== 'string') {
throw new Error(
`Jest watch plugin ${
pluginModulePath
} must export 'prompt' as a string`,
`Jest watch plugin ${pluginModulePath} must export 'prompt' as a string`,
);
}
if (getType(maybePlugin.enter) !== 'function') {
throw new Error(
`Jest watch plugin ${
pluginModulePath
} must export 'enter' as a function`,
`Jest watch plugin ${pluginModulePath} must export 'enter' as a function`,
);
}

const plugin: WatchPlugin = ((maybePlugin: any): WatchPlugin);

if (RESERVED_KEYS.includes(maybePlugin.key)) {
throw new Error(
`Jest watch plugin ${
pluginModulePath
} tried to register reserved key ${String.fromCodePoint(
`Jest watch plugin ${pluginModulePath} tried to register reserved key ${String.fromCodePoint(
maybePlugin.key,
)}`,
);
Expand Down
4 changes: 1 addition & 3 deletions packages/jest-cli/src/reporters/coverage_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,7 @@ export default class CoverageReporter extends BaseReporter {
}
} else if (actual < threshold) {
errors.push(
`Jest: "${name}" coverage threshold for ${key} (${
threshold
}%) not met: ${actual}%`,
`Jest: "${name}" coverage threshold for ${key} (${threshold}%) not met: ${actual}%`,
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/pretty-format/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ result from either:
### test

Write `test` so it can receive `val` argument of any type. To serialize
**objects** which have certain properties, then a guarded expression like `val
!= null && …` or more concise `val && …` prevents the following errors:
**objects** which have certain properties, then a guarded expression like
`val != null && …` or more concise `val && …` prevents the following errors:

* `TypeError: Cannot read property 'whatever' of null`
* `TypeError: Cannot read property 'whatever' of undefined`
Expand Down
4 changes: 1 addition & 3 deletions packages/pretty-format/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,7 @@ const getColorsHighlight = (options: OptionsReceived): Colors =>
colors[key] = color;
} else {
throw new Error(
`pretty-format: Option "theme" has a key "${key}" whose value "${
value
}" is undefined in ansi-styles.`,
`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`,
);
}
return colors;
Expand Down
4 changes: 2 additions & 2 deletions website/blog/2016-06-22-jest-13.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ either git or hg, a common thing in developer tools.
* Added `jest.isMockFunction(jest.fn())` to test for mock functions.
* Improved test reporter printing and added a test failure summary when running
many tests.
* Added support for mocking virtual modules through `jest.mock('Module',
implementation, {virtual: true})`.
* Added support for mocking virtual modules through
`jest.mock('Module', implementation, {virtual: true})`.
* Removed the `.haste_cache` folder. Jest now uses the operating system's
preferred temporary file location.
* Added the duration of individual tests in verbose mode.
Expand Down
5 changes: 3 additions & 2 deletions website/blog/2016-07-27-jest-14.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ able to support a full, unmocked version of React Native. We are excited to
launch experimental React Native support for Jest through the
`jest-react-native` package.

You can start using Jest with react-native by running `npm install --save-dev
jest-react-native` and by adding the preset to your Jest configuration:
You can start using Jest with react-native by running
`npm install --save-dev jest-react-native` and by adding the preset to your Jest
configuration:

```json
"jest": {
Expand Down
Loading

0 comments on commit 0ce82e6

Please sign in to comment.