From 0cbe04d42716928c2f67deac312d01b729b6021a Mon Sep 17 00:00:00 2001 From: Dmitri Date: Wed, 16 Aug 2023 09:05:30 +0300 Subject: [PATCH] fix(expect): remove @types/node from dependencies (#14385) --- CHANGELOG.md | 1 + packages/expect/package.json | 1 - packages/expect/src/types.ts | 3 +-- packages/jest-circus/src/run.ts | 4 +++- packages/jest-snapshot/src/index.ts | 2 +- yarn.lock | 1 - 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79c5d914f531..ea832f3ebb3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixes +- `[expect]` Remove `@types/node` from dependencies ([#14385](https://github.com/jestjs/jest/pull/14385)) - `[jest-reporters]` Update `istanbul-lib-instrument` dependency to v6. ([#14401](https://github.com/jestjs/jest/pull/14401)) ### Chore & Maintenance diff --git a/packages/expect/package.json b/packages/expect/package.json index 8882f53f5002..9ec02caab9b1 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -20,7 +20,6 @@ }, "dependencies": { "@jest/expect-utils": "workspace:^", - "@types/node": "*", "jest-get-type": "workspace:^", "jest-matcher-utils": "workspace:^", "jest-message-util": "workspace:^", diff --git a/packages/expect/src/types.ts b/packages/expect/src/types.ts index 96e858dad93d..e946ebd11e62 100644 --- a/packages/expect/src/types.ts +++ b/packages/expect/src/types.ts @@ -6,7 +6,6 @@ * */ -import type {AsyncLocalStorage} from 'async_hooks'; import type {EqualsFunction, Tester} from '@jest/expect-utils'; import type * as jestMatcherUtils from 'jest-matcher-utils'; import {INTERNAL_MATCHER_FLAG} from './jestMatchersObject'; @@ -58,7 +57,7 @@ export interface MatcherUtils { export interface MatcherState { assertionCalls: number; - currentConcurrentTestName?: AsyncLocalStorage; + currentConcurrentTestName?: () => string | undefined; currentTestName?: string; error?: Error; expand?: boolean; diff --git a/packages/jest-circus/src/run.ts b/packages/jest-circus/src/run.ts index 6564b92e8c45..02766579678f 100644 --- a/packages/jest-circus/src/run.ts +++ b/packages/jest-circus/src/run.ts @@ -137,7 +137,9 @@ function collectConcurrentTests( function startTestsConcurrently(concurrentTests: Array) { const mutex = pLimit(getState().maxConcurrency); const testNameStorage = new AsyncLocalStorage(); - jestExpect.setState({currentConcurrentTestName: testNameStorage}); + jestExpect.setState({ + currentConcurrentTestName: () => testNameStorage.getStore(), + }); for (const test of concurrentTests) { try { const testFn = test.fn; diff --git a/packages/jest-snapshot/src/index.ts b/packages/jest-snapshot/src/index.ts index ee15429a553a..a0344a7daccc 100644 --- a/packages/jest-snapshot/src/index.ts +++ b/packages/jest-snapshot/src/index.ts @@ -281,7 +281,7 @@ const _toMatchSnapshot = (config: MatchSnapshotConfig) => { const {currentConcurrentTestName, isNot, snapshotState} = context; const currentTestName = - currentConcurrentTestName?.getStore() ?? context.currentTestName; + currentConcurrentTestName?.() ?? context.currentTestName; if (isNot) { throw new Error( diff --git a/yarn.lock b/yarn.lock index 221e78957ae1..88827e52c5ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9776,7 +9776,6 @@ __metadata: "@jest/expect-utils": "workspace:^" "@jest/test-utils": "workspace:^" "@tsd/typescript": ^5.0.4 - "@types/node": "*" chalk: ^4.0.0 immutable: ^4.0.0 jest-get-type: "workspace:^"