Skip to content

Commit b7cd432

Browse files
authored
chore: fix some type errors in e2e tests (#9720)
1 parent db055c2 commit b7cd432

19 files changed

Lines changed: 62 additions & 32 deletions

e2e/__tests__/coverageReport.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test('outputs coverage report', () => {
3030
// with 0 % coverage.
3131
expect(wrap(stdout)).toMatchSnapshot();
3232

33-
expect(() => fs.accessSync(coverageDir, fs.F_OK)).not.toThrow();
33+
expect(() => fs.accessSync(coverageDir, fs.constants.F_OK)).not.toThrow();
3434
expect(exitCode).toBe(0);
3535
});
3636

e2e/__tests__/env.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import runJest from '../runJest';
8+
import runJest, {RunJestResult} from '../runJest';
99

10-
const getLog = result => result.stdout.split('\n')[1].trim();
10+
const getLog = (result: RunJestResult) => result.stdout.split('\n')[1].trim();
1111

1212
describe('Environment override', () => {
1313
it('uses jsdom when specified', () => {

e2e/__tests__/hasteMapMockChanged.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import * as path from 'path';
9-
import JestHasteMap from 'jest-haste-map';
9+
import JestHasteMap = require('jest-haste-map');
1010
import {cleanup, writeFiles} from '../Utils';
1111

1212
// Directory must be here for Watchman to be enabled.

e2e/__tests__/hasteMapSha1.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import {tmpdir} from 'os';
99
import * as path from 'path';
10-
import JestHasteMap from 'jest-haste-map';
10+
import JestHasteMap = require('jest-haste-map');
1111
import {cleanup, writeFiles} from '../Utils';
1212

1313
const DIR = path.resolve(tmpdir(), 'haste_map_sha1');

e2e/__tests__/jsonReporter.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import * as fs from 'fs';
99
import * as path from 'path';
10+
import type {FormattedTestResults} from '@jest/test-result';
1011
import runJest from '../runJest';
1112

1213
describe('JSON Reporter', () => {
@@ -22,7 +23,7 @@ describe('JSON Reporter', () => {
2223
});
2324

2425
it('writes test result to sum.result.json', () => {
25-
let jsonResult;
26+
let jsonResult: FormattedTestResults;
2627

2728
runJest('json-reporter', ['--json', `--outputFile=${outputFileName}`]);
2829
const testOutput = fs.readFileSync(outputFilePath, 'utf8');
@@ -45,7 +46,7 @@ describe('JSON Reporter', () => {
4546
const noAncestors = jsonResult.testResults[0].assertionResults.find(
4647
item => item.title == 'no ancestors',
4748
);
48-
let expected = {ancestorTitles: []};
49+
let expected = {ancestorTitles: [] as Array<string>};
4950
expect(noAncestors).toEqual(expect.objectContaining(expected));
5051

5152
const addsNumbers = jsonResult.testResults[0].assertionResults.find(
@@ -63,7 +64,7 @@ describe('JSON Reporter', () => {
6364

6465
it('outputs coverage report', () => {
6566
const result = runJest('json-reporter', ['--json']);
66-
let jsonResult;
67+
let jsonResult: FormattedTestResults;
6768

6869
expect(result.stderr).toMatch(/1 failed, 2 passed/);
6970
expect(result.exitCode).toBe(1);
@@ -86,7 +87,7 @@ describe('JSON Reporter', () => {
8687
const noAncestors = jsonResult.testResults[0].assertionResults.find(
8788
item => item.title == 'no ancestors',
8889
);
89-
let expected = {ancestorTitles: []};
90+
let expected = {ancestorTitles: [] as Array<string>};
9091
expect(noAncestors).toEqual(expect.objectContaining(expected));
9192

9293
const addsNumbers = jsonResult.testResults[0].assertionResults.find(

e2e/__tests__/listTests.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import runJest from '../runJest';
1111

1212
const testRootDir = path.resolve(__dirname, '..', '..');
1313

14-
const normalizePaths = rawPaths =>
14+
const normalizePaths = (rawPaths: string) =>
1515
rawPaths
1616
.split(testRootDir)
1717
.join(`${path.sep}MOCK_ABOLUTE_PATH`)

e2e/__tests__/nodePath.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import runJest from '../runJest';
99

1010
test('supports NODE_PATH', () => {
1111
const result = runJest('node-path', [], {
12-
nodePath: ['../node-path/src'],
12+
nodePath: '../node-path/src',
1313
});
1414
expect(result.exitCode).toBe(0);
1515
});

e2e/__tests__/overrideGlobals.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test('has a duration even if time is faked', () => {
1818

1919
expect(stderr).toMatch(regex);
2020

21-
const [, duration] = stderr.match(regex);
21+
const [, duration] = stderr.match(regex)!;
2222

2323
expect(Number(duration)).toBeGreaterThan(0);
2424
});

e2e/__tests__/showConfig.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ test('--showConfig outputs config info and exits', () => {
3737
.replace(/"name": "(.+)"/g, '"name": "[md5 hash]"')
3838
.replace(/"version": "(.+)"/g, '"version": "[version]"')
3939
.replace(/"maxWorkers": (\d+)/g, '"maxWorkers": "[maxWorkers]"')
40-
.replace(/\"\S*show-config-test/gm, '"<<REPLACED_ROOT_DIR>>')
41-
.replace(/\"\S*\/jest\/packages/gm, '"<<REPLACED_JEST_PACKAGES_DIR>>');
40+
.replace(/"\S*show-config-test/gm, '"<<REPLACED_ROOT_DIR>>')
41+
.replace(/"\S*\/jest\/packages/gm, '"<<REPLACED_JEST_PACKAGES_DIR>>');
4242

4343
expect(wrap(stdout)).toMatchSnapshot();
4444
});

e2e/__tests__/testEnvironment.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import {json as runWithJson} from '../runJest';
99

10-
import testFixturePackage from '../test-environment/package.json';
10+
import * as testFixturePackage from '../test-environment/package.json';
1111

1212
it('respects testEnvironment docblock', () => {
1313
expect(testFixturePackage.jest.testEnvironment).toEqual('node');

0 commit comments

Comments
 (0)