From 4f1285e7ae0c7380cd2bf9f4cf28af61a35c28a1 Mon Sep 17 00:00:00 2001 From: Dmitri Gabbasov Date: Fri, 4 Aug 2023 00:31:10 +0300 Subject: [PATCH 1/2] fix(expect): remove @types/node from dependencies --- CHANGELOG.md | 2 ++ 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, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 953ca6b204ca..263ec6368978 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Fixes +- `[expect]` Remove `@types/node` from dependencies + ### Chore & Maintenance ### Performance diff --git a/packages/expect/package.json b/packages/expect/package.json index 08b75c77559d..8b780caae0f1 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 1a618ceaeeef..2787be934181 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:^" From 0e5666681b622e395eabc1e9ac914bc8e7dd23d9 Mon Sep 17 00:00:00 2001 From: Dmitri Gabbasov Date: Fri, 4 Aug 2023 00:40:05 +0300 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 263ec6368978..8a2ba8ffc656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Fixes -- `[expect]` Remove `@types/node` from dependencies +- `[expect]` Remove `@types/node` from dependencies ([#14385](https://github.com/jestjs/jest/pull/14385)) ### Chore & Maintenance