Skip to content

Commit 53bd046

Browse files
authored
flowtype packages tests jestjs#1 (jestjs#4130)
1 parent 45b0ad7 commit 53bd046

File tree

8 files changed

+74
-20
lines changed

8 files changed

+74
-20
lines changed

.eslintrc.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,20 @@ module.exports = {
9090
},
9191
},
9292
{
93-
files: ['integration_tests/__tests__/**/*'],
93+
files: [
94+
'integration_tests/__tests__/**/*',
95+
'packages/babel-jest/**/*.test.js',
96+
'packages/babel-plugin-jest-hoist/**/*.test.js',
97+
'packages/babel-preset-jest/**/*.test.js',
98+
'packages/eslint-config-fb-strict/**/*.test.js',
99+
'packages/eslint-plugin-jest/**/*.test.js',
100+
'packages/jest/**/*.test.js',
101+
'packages/jest-changed-files/**/*.test.js',
102+
'packages/jest-circus/**/*.test.js',
103+
'packages/jest-diff/**/*.test.js',
104+
'packages/jest-docblock/**/*.test.js',
105+
'packages/jest-editor-support/**/*.test.js',
106+
],
94107
rules: {
95108
'flowtype/require-valid-file-annotation': [2, 'always'],
96109
},

packages/jest-diff/src/__tests__/diff.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree. An additional grant
66
* of patent rights can be found in the PATENTS file in the same directory.
77
*
8-
* @emails oncall+jsinfra
8+
* @flow
99
*/
1010

1111
const stripAnsi = require('strip-ansi');
@@ -28,7 +28,7 @@ describe('different types', () => {
2828
const typeA = values[2];
2929
const typeB = values[3];
3030

31-
test(`'${a}' and '${b}'`, () => {
31+
test(`'${String(a)}' and '${String(b)}'`, () => {
3232
expect(stripAnsi(diff(a, b))).toBe(
3333
' Comparing two different types of values. ' +
3434
`Expected ${typeA} but received ${typeB}.`,

packages/jest-docblock/src/__tests__/index.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* LICENSE file in the root directory of this source tree. An additional grant
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*
9-
* @emails oncall+jsinfra
9+
* @flow
1010
*/
1111

1212
'use strict';

packages/jest-editor-support/src/__tests__/parsers/babylon_parser.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* This source code is licensed under the BSD-style license found in the
55
* LICENSE file in the root directory of this source tree. An additional grant
66
* of patent rights can be found in the PATENTS file in the same directory.
7+
*
8+
* @flow
79
*/
810

911
'use strict';

packages/jest-editor-support/src/__tests__/project_workspace.test.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* This source code is licensed under the BSD-style license found in the
55
* LICENSE file in the root directory of this source tree. An additional grant
66
* of patent rights can be found in the PATENTS file in the same directory.
7+
*
8+
* @flow
79
*/
810

911
'use strict';
@@ -12,7 +14,12 @@ const ProjectWorkspace = require('../project_workspace');
1214

1315
describe('setup', () => {
1416
it('sets itself up fom the constructor', () => {
15-
const workspace = new ProjectWorkspace('root_path', 'path_to_jest');
17+
const workspace = new ProjectWorkspace(
18+
'root_path',
19+
'path_to_jest',
20+
'path_to_config',
21+
1000,
22+
);
1623
expect(workspace.rootPath).toEqual('root_path');
1724
expect(workspace.pathToJest).toEqual('path_to_jest');
1825
});

packages/jest-editor-support/src/__tests__/runner.test.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* This source code is licensed under the BSD-style license found in the
55
* LICENSE file in the root directory of this source tree. An additional grant
66
* of patent rights can be found in the PATENTS file in the same directory.
7+
*
8+
* @flow
79
*/
810

911
'use strict';
@@ -42,9 +44,14 @@ describe('events', () => {
4244

4345
beforeEach(() => {
4446
mockCreateProcess.mockClear();
45-
const workspace = new ProjectWorkspace('.', 'node_modules/.bin/jest', 18);
47+
const workspace = new ProjectWorkspace(
48+
'.',
49+
'node_modules/.bin/jest',
50+
'test',
51+
18,
52+
);
4653
runner = new Runner(workspace);
47-
fakeProcess = new EventEmitter();
54+
fakeProcess = (new EventEmitter(): any);
4855
fakeProcess.stdout = new EventEmitter();
4956
fakeProcess.stderr = new EventEmitter();
5057
mockDebugProcess = fakeProcess;
@@ -66,7 +73,7 @@ describe('events', () => {
6673

6774
// And lets check what we emit
6875
const dataAtPath = readFileSync(runner.outputPath);
69-
const storedJSON = JSON.parse(dataAtPath);
76+
const storedJSON = JSON.parse(dataAtPath.toString());
7077
expect(data.mock.calls[0][0]).toEqual(storedJSON);
7178
});
7279

packages/jest-editor-support/src/__tests__/settings.test.js

+20-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* This source code is licensed under the BSD-style license found in the
55
* LICENSE file in the root directory of this source tree. An additional grant
66
* of patent rights can be found in the PATENTS file in the same directory.
7+
*
8+
* @flow
79
*/
810

911
'use strict';
@@ -14,14 +16,24 @@ const Settings = require('../Settings');
1416

1517
describe('Settings', () => {
1618
it('sets itself up fom the constructor', () => {
17-
const workspace = new ProjectWorkspace('root_path', 'path_to_jest');
19+
const workspace = new ProjectWorkspace(
20+
'root_path',
21+
'path_to_jest',
22+
'test',
23+
1000,
24+
);
1825
const settings = new Settings(workspace);
1926
expect(settings.workspace).toEqual(workspace);
2027
expect(settings.settings).toEqual(expect.any(Object));
2128
});
2229

2330
it('reads and parses the config', () => {
24-
const workspace = new ProjectWorkspace('root_path', 'path_to_jest');
31+
const workspace = new ProjectWorkspace(
32+
'root_path',
33+
'path_to_jest',
34+
'test',
35+
1000,
36+
);
2537
const completed = jest.fn();
2638
const config = {cacheDirectory: '/tmp/jest', name: '[md5 hash]'};
2739
const json = {
@@ -45,7 +57,12 @@ describe('Settings', () => {
4557
});
4658

4759
it('calls callback even if no data is sent', () => {
48-
const workspace = new ProjectWorkspace('root_path', 'path_to_jest');
60+
const workspace = new ProjectWorkspace(
61+
'root_path',
62+
'path_to_jest',
63+
'test',
64+
1000,
65+
);
4966
const completed = jest.fn();
5067

5168
const mockProcess: any = new EventEmitter();

packages/jest-editor-support/src/__tests__/test_reconciler.test.js

+17-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* This source code is licensed under the BSD-style license found in the
55
* LICENSE file in the root directory of this source tree. An additional grant
66
* of patent rights can be found in the PATENTS file in the same directory.
7+
*
8+
* @flow
79
*/
810

911
const fs = require('fs');
@@ -29,7 +31,10 @@ describe('Test Reconciler', () => {
2931
it('passes a passing method', () => {
3032
parser = reconcilerWithFile('failing_jest_json.json');
3133
const testName = 'does not validate without josh';
32-
const status = parser.stateForTestAssertion(dangerFilePath, testName);
34+
const status: any = parser.stateForTestAssertion(
35+
dangerFilePath,
36+
testName,
37+
);
3338
expect(status.status).toEqual('KnownSuccess');
3439
expect(status.line).toBeNull();
3540
});
@@ -40,7 +45,10 @@ describe('Test Reconciler', () => {
4045
'validates when all Travis environment' +
4146
' vars are set and Josh K says so';
4247

43-
const status = parser.stateForTestAssertion(dangerFilePath, testName);
48+
const status: any = parser.stateForTestAssertion(
49+
dangerFilePath,
50+
testName,
51+
);
4452
expect(status.status).toEqual('KnownFail');
4553
expect(status.line).toEqual(12);
4654
const errorMessage = 'Expected value to be falsy, instead received true';
@@ -64,30 +72,30 @@ describe('Terse Messages', () => {
6472

6573
let message = 'Expected value to equal: 2, Received: 1';
6674
let testName = 'numbers';
67-
expect(terseForTest(testName).terseMessage).toEqual(message);
75+
expect(terseForTest(testName)).toHaveProperty('terseMessage', message);
6876

6977
message = 'Expected value to equal: 2, Received: "1"';
7078
testName = 'string to numbers: numbers';
71-
expect(terseForTest(testName).terseMessage).toEqual(message);
79+
expect(terseForTest(testName)).toHaveProperty('terseMessage', message);
7280

7381
message = 'Expected value to equal: {"a": 2}, Received: {}';
7482
testName = 'objects';
75-
expect(terseForTest(testName).terseMessage).toEqual(message);
83+
expect(terseForTest(testName)).toHaveProperty('terseMessage', message);
7684

7785
message = 'Snapshot has changed';
7886
testName = 'snapshots';
79-
expect(terseForTest(testName).terseMessage).toEqual(message);
87+
expect(terseForTest(testName)).toHaveProperty('terseMessage', message);
8088

8189
message = 'Expected value to be greater than: 3, Received: 2';
8290
testName = 'greater than';
83-
expect(terseForTest(testName).terseMessage).toEqual(message);
91+
expect(terseForTest(testName)).toHaveProperty('terseMessage', message);
8492

8593
message = 'Expected value to be falsy, instead received 2';
8694
testName = 'falsy';
87-
expect(terseForTest(testName).terseMessage).toEqual(message);
95+
expect(terseForTest(testName)).toHaveProperty('terseMessage', message);
8896

8997
message = 'Expected value to be truthy, instead received null';
9098
testName = 'truthy';
91-
expect(terseForTest(testName).terseMessage).toEqual(message);
99+
expect(terseForTest(testName)).toHaveProperty('terseMessage', message);
92100
});
93101
});

0 commit comments

Comments
 (0)