Skip to content

Commit 6877134

Browse files
committed
Merge branch 'main' into feat/programmatic-api
2 parents 0b6f93d + 46e6ed8 commit 6877134

File tree

19 files changed

+55
-43
lines changed

19 files changed

+55
-43
lines changed

packages/jest-console/src/CustomConsole.ts

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

88
import {AssertionError, strict as assert} from 'assert';
99
import {Console} from 'console';
10+
import type {WriteStream} from 'tty';
1011
import {InspectOptions, format, formatWithOptions, inspect} from 'util';
1112
import chalk = require('chalk');
1213
import {clearLine, formatTime} from 'jest-util';
@@ -15,8 +16,8 @@ import type {LogCounters, LogMessage, LogTimers, LogType} from './types';
1516
type Formatter = (type: LogType, message: LogMessage) => string;
1617

1718
export default class CustomConsole extends Console {
18-
private readonly _stdout: NodeJS.WriteStream;
19-
private readonly _stderr: NodeJS.WriteStream;
19+
private readonly _stdout: WriteStream;
20+
private readonly _stderr: WriteStream;
2021
private readonly _formatBuffer: Formatter;
2122
private _counters: LogCounters = {};
2223
private _timers: LogTimers = {};
@@ -25,8 +26,8 @@ export default class CustomConsole extends Console {
2526
override Console: typeof Console = Console;
2627

2728
constructor(
28-
stdout: NodeJS.WriteStream,
29-
stderr: NodeJS.WriteStream,
29+
stdout: WriteStream,
30+
stderr: WriteStream,
3031
formatBuffer: Formatter = (_type, message) => message,
3132
) {
3233
super(stdout, stderr);

packages/jest-console/src/__tests__/CustomConsole.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
import {Writable} from 'stream';
9+
import type {WriteStream} from 'tty';
910
import chalk = require('chalk');
1011
import CustomConsole from '../CustomConsole';
1112

@@ -23,14 +24,14 @@ describe('CustomConsole', () => {
2324
_stdout += chunk.toString();
2425
callback();
2526
},
26-
}) as NodeJS.WriteStream;
27+
}) as WriteStream;
2728

2829
const stderr = new Writable({
2930
write(chunk: string, _encoding, callback) {
3031
_stderr += chunk.toString();
3132
callback();
3233
},
33-
}) as NodeJS.WriteStream;
34+
}) as WriteStream;
3435

3536
_console = new CustomConsole(stdout, stderr);
3637
});

packages/jest-core/src/__tests__/watchFileChanges.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import {tmpdir} from 'os';
1010
import * as path from 'path';
11+
import type {WriteStream} from 'tty';
1112
import * as fs from 'graceful-fs';
1213
import type {AggregatedResult} from '@jest/test-result';
1314
import {normalize} from 'jest-config';
@@ -20,7 +21,7 @@ describe('Watch mode flows with changed files', () => {
2021
jest.resetModules();
2122

2223
let watch: typeof import('../watch').default;
23-
let pipe: NodeJS.WriteStream;
24+
let pipe: WriteStream;
2425
let stdin: MockStdin;
2526
const testDirectory = path.resolve(tmpdir(), 'jest-tmp');
2627
const fileTargetPath = path.resolve(testDirectory, 'lost-file.js');

packages/jest-core/src/jest.ts

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

88
import {performance} from 'perf_hooks';
9+
import type {WriteStream} from 'tty';
910
import exit = require('exit');
1011
import {CustomConsole} from '@jest/console';
1112
import type {AggregatedResult, TestContext} from '@jest/test-result';
@@ -78,7 +79,7 @@ export const createJest = Jest.createJest;
7879
const buildContextsAndHasteMaps = async (
7980
configs: Array<Config.ProjectConfig>,
8081
globalConfig: Config.GlobalConfig,
81-
outputStream: NodeJS.WriteStream,
82+
outputStream: WriteStream,
8283
) => {
8384
const hasteMapInstances = Array(configs.length);
8485
const contexts = await Promise.all(
@@ -107,7 +108,7 @@ export const _run = async (
107108
globalConfig: Config.GlobalConfig,
108109
configs: Array<Config.ProjectConfig>,
109110
hasDeprecationWarnings: boolean,
110-
outputStream: NodeJS.WriteStream,
111+
outputStream: WriteStream,
111112
): Promise<AggregatedResult> => {
112113
// Queries to hg/git can take a while, so we need to start the process
113114
// as soon as possible, so by the time we need the result it's already there.
@@ -193,7 +194,7 @@ const runWatch = async (
193194
_configs: Array<Config.ProjectConfig>,
194195
hasDeprecationWarnings: boolean,
195196
globalConfig: Config.GlobalConfig,
196-
outputStream: NodeJS.WriteStream,
197+
outputStream: WriteStream,
197198
hasteMapInstances: Array<IHasteMap>,
198199
filter?: Filter,
199200
) => {
@@ -228,7 +229,7 @@ const runWatch = async (
228229
const runWithoutWatch = async (
229230
globalConfig: Config.GlobalConfig,
230231
contexts: Array<TestContext>,
231-
outputStream: NodeJS.WriteStream,
232+
outputStream: WriteStream,
232233
onComplete: OnCompleteCallback,
233234
changedFilesPromise?: ChangedFilesPromise,
234235
filter?: Filter,

packages/jest-core/src/lib/__tests__/logDebugMessages.test.ts

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

9+
import type {WriteStream} from 'tty';
910
import {makeGlobalConfig, makeProjectConfig} from '@jest/test-utils';
1011
import logDebugMessages from '../logDebugMessages';
1112

@@ -18,7 +19,7 @@ const getOutputStream = (resolve: (message: string) => void) =>
1819
write(message: string) {
1920
resolve(message);
2021
},
21-
}) as NodeJS.WriteStream;
22+
}) as WriteStream;
2223

2324
it('prints the jest version', async () => {
2425
expect.assertions(1);

packages/jest-core/src/lib/handleDeprecationWarnings.ts

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

8+
import type {ReadStream, WriteStream} from 'tty';
89
import chalk = require('chalk');
910
import {KEYS} from 'jest-watcher';
1011

1112
export default function handleDeprecationWarnings(
12-
pipe: NodeJS.WriteStream,
13-
stdin: NodeJS.ReadStream = process.stdin,
13+
pipe: WriteStream,
14+
stdin: ReadStream = process.stdin,
1415
): Promise<void> {
1516
return new Promise((resolve, reject) => {
1617
if (typeof stdin.setRawMode === 'function') {

packages/jest-core/src/lib/logDebugMessages.ts

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

8+
import type {WriteStream} from 'tty';
89
import type {Config} from '@jest/types';
910
const VERSION = require('../../package.json').version;
1011

1112
// if the output here changes, update `getConfig` in e2e/runJest.ts
1213
export default function logDebugMessages(
1314
globalConfig: Config.GlobalConfig,
1415
configs: Array<Config.ProjectConfig> | Config.ProjectConfig,
15-
outputStream: NodeJS.WriteStream,
16+
outputStream: WriteStream,
1617
): void {
1718
const output = {
1819
configs,

packages/jest-core/src/plugins/Quit.ts

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

8+
import type {ReadStream, WriteStream} from 'tty';
89
import {BaseWatchPlugin, UsageData} from 'jest-watcher';
910

1011
class QuitPlugin extends BaseWatchPlugin {
1112
isInternal: true;
1213

13-
constructor(options: {stdin: NodeJS.ReadStream; stdout: NodeJS.WriteStream}) {
14+
constructor(options: {stdin: ReadStream; stdout: WriteStream}) {
1415
super(options);
1516
this.isInternal = true;
1617
}

packages/jest-core/src/plugins/TestNamePattern.ts

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

8+
import type {ReadStream, WriteStream} from 'tty';
89
import type {Config} from '@jest/types';
910
import {
1011
BaseWatchPlugin,
@@ -19,7 +20,7 @@ class TestNamePatternPlugin extends BaseWatchPlugin {
1920
_prompt: Prompt;
2021
isInternal: true;
2122

22-
constructor(options: {stdin: NodeJS.ReadStream; stdout: NodeJS.WriteStream}) {
23+
constructor(options: {stdin: ReadStream; stdout: WriteStream}) {
2324
super(options);
2425
this._prompt = new Prompt();
2526
this.isInternal = true;

packages/jest-core/src/plugins/TestPathPattern.ts

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

8+
import type {ReadStream, WriteStream} from 'tty';
89
import type {Config} from '@jest/types';
910
import {
1011
BaseWatchPlugin,
@@ -19,7 +20,7 @@ class TestPathPatternPlugin extends BaseWatchPlugin {
1920
private readonly _prompt: Prompt;
2021
isInternal: true;
2122

22-
constructor(options: {stdin: NodeJS.ReadStream; stdout: NodeJS.WriteStream}) {
23+
constructor(options: {stdin: ReadStream; stdout: WriteStream}) {
2324
super(options);
2425
this._prompt = new Prompt();
2526
this.isInternal = true;

0 commit comments

Comments
 (0)