Skip to content

Commit

Permalink
chore: update to prettier@2 (#9692)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Mar 23, 2020
1 parent 1c01e68 commit 244f7dc
Show file tree
Hide file tree
Showing 110 changed files with 332 additions and 380 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
- image: circleci/node:8
steps:
- checkout
- run:
command: yarn remove-prettier-dep
- restore-cache: *restore-cache
- run: *install
- save-cache: *save-cache
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: remove prettier dep
run: yarn remove-prettier-dep
if: matrix.node-version == '8.17.0'
- name: install
run: yarn install-no-ts-build
- name: run tests
Expand Down
2 changes: 1 addition & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ module.exports = async () => {

```js
// teardown.js
module.exports = async function() {
module.exports = async function () {
await global.__MONGOD__.stop();
};
```
Expand Down
2 changes: 1 addition & 1 deletion docs/Es6ClassMocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ In order to mock a constructor function, the module factory must return a constr

```javascript
jest.mock('./sound-player', () => {
return function() {
return function () {
return {playSoundFile: () => {}};
};
});
Expand Down
2 changes: 1 addition & 1 deletion docs/MockFunctionAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Expected mock function "mockedFunction" to have been called, but it was not call
Syntactic sugar function for:

```js
jest.fn(function() {
jest.fn(function () {
return this;
});
```
Expand Down
9 changes: 3 additions & 6 deletions docs/MockFunctions.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ const myMock = jest.fn();
console.log(myMock());
// > undefined

myMock
.mockReturnValueOnce(10)
.mockReturnValueOnce('x')
.mockReturnValue(true);
myMock.mockReturnValueOnce(10).mockReturnValueOnce('x').mockReturnValue(true);

console.log(myMock(), myMock(), myMock(), myMock());
// > 10, 'x', true, true
Expand Down Expand Up @@ -169,7 +166,7 @@ The `mockImplementation` method is useful when you need to define the default im

```js
// foo.js
module.exports = function() {
module.exports = function () {
// some implementation;
};

Expand Down Expand Up @@ -220,7 +217,7 @@ const myObj = {
// is the same as

const otherObj = {
myMethod: jest.fn(function() {
myMethod: jest.fn(function () {
return this;
}),
};
Expand Down
4 changes: 2 additions & 2 deletions docs/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const os = require('os');

const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');

module.exports = async function() {
module.exports = async function () {
const browser = await puppeteer.launch();
// store the browser instance so we can teardown it later
// this global is only available in the teardown but not in TestEnvironments
Expand Down Expand Up @@ -127,7 +127,7 @@ const rimraf = require('rimraf');
const path = require('path');

const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');
module.exports = async function() {
module.exports = async function () {
// close the browser instance
await global.__BROWSER_GLOBAL__.close();

Expand Down
2 changes: 1 addition & 1 deletion e2e/MockStdinWatchPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MockStdinWatchPlugin {
constructor({stdin, config}) {
this._stdin = stdin;
if (typeof this._stdin.setRawMode !== 'function') {
this._stdin.setRawMode = function() {};
this._stdin.setRawMode = function () {};
}
this._config = config;
}
Expand Down
5 changes: 1 addition & 4 deletions e2e/__tests__/environmentAfterTeardown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import runJest from '../runJest';

test('prints useful error for environment methods after test is done', () => {
const {stderr} = runJest('environment-after-teardown');
const interestingLines = stderr
.split('\n')
.slice(9, 18)
.join('\n');
const interestingLines = stderr.split('\n').slice(9, 18).join('\n');

expect(wrap(interestingLines)).toMatchSnapshot();
expect(stderr.split('\n')[9]).toBe(
Expand Down
15 changes: 2 additions & 13 deletions e2e/__tests__/listTests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ describe('--listTests flag', () => {

expect(exitCode).toBe(0);
expect(
wrap(
normalizePaths(stdout)
.split('\n')
.sort()
.join('\n'),
),
wrap(normalizePaths(stdout).split('\n').sort().join('\n')),
).toMatchSnapshot();
});

Expand All @@ -39,13 +34,7 @@ describe('--listTests flag', () => {
expect(exitCode).toBe(0);
expect(() => JSON.parse(stdout)).not.toThrow();
expect(
wrap(
JSON.stringify(
JSON.parse(stdout)
.map(normalizePaths)
.sort(),
),
),
wrap(JSON.stringify(JSON.parse(stdout).map(normalizePaths).sort())),
).toMatchSnapshot();
});
});
5 changes: 1 addition & 4 deletions e2e/__tests__/requireAfterTeardown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import runJest from '../runJest';
test('prints useful error for requires after test is done', () => {
const {stderr} = runJest('require-after-teardown');

const interestingLines = stderr
.split('\n')
.slice(9, 18)
.join('\n');
const interestingLines = stderr.split('\n').slice(9, 18).join('\n');

expect(wrap(interestingLines)).toMatchSnapshot();
expect(stderr.split('\n')[19]).toMatch(
Expand Down
2 changes: 1 addition & 1 deletion e2e/coverage-report/notRequiredInTestSuite.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ throw new Error(

// Flow annotations to make sure istanbul can instrument non ES6 source
// eslint-disable-next-line no-unreachable
module.exports = function(j: string, d: string): string {
module.exports = function (j: string, d: string): string {
if (j) {
return d;
} else {
Expand Down
2 changes: 1 addition & 1 deletion e2e/filter/my-broken-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

'use strict';

module.exports = function(tests) {
module.exports = function (tests) {
return new Promise((resolve, reject) => {
reject(new Error('My broken filter error.'));
});
Expand Down
4 changes: 2 additions & 2 deletions e2e/filter/my-broken-setup-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

'use strict';

module.exports = function(tests) {
module.exports = function (tests) {
return {
filtered: tests.filter(t => t.indexOf('foo') !== -1).map(test => ({test})),
};
};

module.exports.setup = function() {
module.exports.setup = function () {
return new Promise((resolve, reject) => {
setTimeout(() => {
reject(new Error('My broken setup filter error.'));
Expand Down
2 changes: 1 addition & 1 deletion e2e/filter/my-clowny-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

'use strict';

module.exports = function(tests) {
module.exports = function (tests) {
return {
filtered: 'potato',
};
Expand Down
2 changes: 1 addition & 1 deletion e2e/filter/my-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

'use strict';

module.exports = function(tests) {
module.exports = function (tests) {
return new Promise(resolve => {
setTimeout(() => {
resolve({
Expand Down
2 changes: 1 addition & 1 deletion e2e/filter/my-secondary-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

'use strict';

module.exports = function(tests) {
module.exports = function (tests) {
return {
filtered: tests.filter(t => t.indexOf('foo') !== -1).map(test => ({test})),
};
Expand Down
4 changes: 2 additions & 2 deletions e2e/filter/my-setup-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const setupData = {
filterText: 'this will return no tests',
};

module.exports = function(tests) {
module.exports = function (tests) {
return {
filtered: tests
.filter(t => t.indexOf(setupData.filterText) !== -1)
.map(test => ({test})),
};
};

module.exports.setup = function() {
module.exports.setup = function () {
return new Promise(resolve => {
setTimeout(() => {
setupData.filterText = 'foo';
Expand Down
2 changes: 1 addition & 1 deletion e2e/global-setup-custom-transform/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const path = require('path');

const DIR = path.join(os.tmpdir(), 'jest-global-setup-custom-transform');

module.exports = function() {
module.exports = function () {
return new Promise(resolve => {
createDirectory(DIR);
const fileId = crypto.randomBytes(20).toString('hex');
Expand Down
2 changes: 1 addition & 1 deletion e2e/global-setup-node-modules/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const path = require('path');

const DIR = path.join(os.tmpdir(), 'jest-global-setup-node-modules');

module.exports = function() {
module.exports = function () {
return new Promise(resolve => {
createDirectory(DIR);
const fileId = crypto.randomBytes(20).toString('hex');
Expand Down
2 changes: 1 addition & 1 deletion e2e/global-setup/project-1/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const path = require('path');

const DIR = path.join(os.tmpdir(), 'jest-global-setup-project-1');

module.exports = function() {
module.exports = function () {
return new Promise((resolve, reject) => {
createDirectory(DIR);
const fileId = crypto.randomBytes(20).toString('hex');
Expand Down
2 changes: 1 addition & 1 deletion e2e/global-setup/project-2/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const path = require('path');

const DIR = path.join(os.tmpdir(), 'jest-global-setup-project-2');

module.exports = function() {
module.exports = function () {
return new Promise((resolve, reject) => {
createDirectory(DIR);
const fileId = crypto.randomBytes(20).toString('hex');
Expand Down
2 changes: 1 addition & 1 deletion e2e/global-setup/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const path = require('path');

const DIR = path.join(os.tmpdir(), 'jest-global-setup');

module.exports = function() {
module.exports = function () {
// This uses a flow annotation to show it can be transpiled
return new Promise((resolve, reject: any) => {
createDirectory(DIR);
Expand Down
2 changes: 1 addition & 1 deletion e2e/global-setup/setupWithConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

module.exports = function(jestConfig) {
module.exports = function (jestConfig) {
console.log(jestConfig.testPathPattern);
};
2 changes: 1 addition & 1 deletion e2e/global-setup/setupWithDefaultExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

export default function(jestConfig): void {
export default function (jestConfig): void {
console.log(jestConfig.testPathPattern);
}
2 changes: 1 addition & 1 deletion e2e/global-teardown/project-1/teardown.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const path = require('path');

const DIR = path.join(os.tmpdir(), 'jest-global-teardown-project-1');

module.exports = function() {
module.exports = function () {
return new Promise((resolve, reject) => {
createDirectory(DIR);
const fileId = crypto.randomBytes(20).toString('hex');
Expand Down
2 changes: 1 addition & 1 deletion e2e/global-teardown/project-2/teardown.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const path = require('path');

const DIR = path.join(os.tmpdir(), 'jest-global-teardown-project-2');

module.exports = function() {
module.exports = function () {
return new Promise((resolve, reject) => {
createDirectory(DIR);
const fileId = crypto.randomBytes(20).toString('hex');
Expand Down
2 changes: 1 addition & 1 deletion e2e/global-teardown/teardown.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const path = require('path');

const DIR = path.join(os.tmpdir(), 'jest-global-teardown');

module.exports = function() {
module.exports = function () {
return new Promise((resolve, reject) => {
createDirectory(DIR);
const fileId = crypto.randomBytes(20).toString('hex');
Expand Down
2 changes: 1 addition & 1 deletion e2e/global-teardown/teardownWithConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

module.exports = function(jestConfig) {
module.exports = function (jestConfig) {
console.log(jestConfig.testPathPattern);
};
2 changes: 1 addition & 1 deletion e2e/global-teardown/teardownWithDefaultExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

export default function(jestConfig): void {
export default function (jestConfig): void {
console.log(jestConfig.testPathPattern);
}
4 changes: 2 additions & 2 deletions e2e/jasmine-async/__tests__/generator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ function* someFunc() {
}

describe('generators', () => {
beforeEach(function*() {
beforeEach(function* () {
// This shouldn't throw
yield someFunc();
});

it('in spec', function*() {
it('in spec', function* () {
const data = yield someFunc();

expect(data).toBe(3);
Expand Down
2 changes: 1 addition & 1 deletion e2e/json-reporter/sum.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

module.exports = function(a, b) {
module.exports = function (a, b) {
return a + b;
};
2 changes: 1 addition & 1 deletion e2e/override-globals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

global.Promise = function() {
global.Promise = function () {
throw new Error('Booo');
};
4 changes: 2 additions & 2 deletions e2e/runJest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function normalizeStdoutAndStderr(
// 'success', 'startTime', 'numTotalTests', 'numTotalTestSuites',
// 'numRuntimeErrorTestSuites', 'numPassedTests', 'numFailedTests',
// 'numPendingTests', 'testResults'
export const json = function(
export const json = function (
dir: string,
args: Array<string> | undefined,
options: RunJestOptions = {},
Expand Down Expand Up @@ -141,7 +141,7 @@ type ConditionFunction = (arg: StdErrAndOutString) => boolean;

// Runs `jest` continously (watch mode) and allows the caller to wait for
// conditions on stdout and stderr and to end the process.
export const runContinuous = function(
export const runContinuous = function (
dir: string,
args?: Array<string>,
options: RunJestOptions = {},
Expand Down
2 changes: 1 addition & 1 deletion e2e/runtime-internal-module-registry/__mocks__/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function mkdirSync() {
}

fs.mkdirSync = mkdirSync;
fs.__wasMkdirCalled = function() {
fs.__wasMkdirCalled = function () {
return mkdirWasCalled;
};

Expand Down

0 comments on commit 244f7dc

Please sign in to comment.