Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(expect): remove @types/node from dependencies #14385

Merged
merged 3 commits into from Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,8 @@

### Fixes

- `[expect]` Remove `@types/node` from dependencies ([#14385](https://github.com/jestjs/jest/pull/14385))

### Chore & Maintenance

### Performance
Expand Down
1 change: 0 additions & 1 deletion packages/expect/package.json
Expand Up @@ -20,7 +20,6 @@
},
"dependencies": {
"@jest/expect-utils": "workspace:^",
"@types/node": "*",
"jest-get-type": "workspace:^",
"jest-matcher-utils": "workspace:^",
"jest-message-util": "workspace:^",
Expand Down
3 changes: 1 addition & 2 deletions packages/expect/src/types.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -58,7 +57,7 @@ export interface MatcherUtils {

export interface MatcherState {
assertionCalls: number;
currentConcurrentTestName?: AsyncLocalStorage<string>;
currentConcurrentTestName?: () => string | undefined;
Comment on lines -61 to +60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like breaking change, or?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. Not sure if it's breaking enough, tho... 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, breaking for anyone that calls jestExpect.setState with this property or anyone that reads it inside a custom matcher. Since the property was only added in v29.6.0 then I'm pretty sure only Jest itself does that 😅

currentTestName?: string;
error?: Error;
expand?: boolean;
Expand Down
4 changes: 3 additions & 1 deletion packages/jest-circus/src/run.ts
Expand Up @@ -137,7 +137,9 @@ function collectConcurrentTests(
function startTestsConcurrently(concurrentTests: Array<ConcurrentTestEntry>) {
const mutex = pLimit(getState().maxConcurrency);
const testNameStorage = new AsyncLocalStorage<string>();
jestExpect.setState({currentConcurrentTestName: testNameStorage});
jestExpect.setState({
currentConcurrentTestName: () => testNameStorage.getStore(),
});
for (const test of concurrentTests) {
try {
const testFn = test.fn;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-snapshot/src/index.ts
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion yarn.lock
Expand Up @@ -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:^"
Expand Down