Skip to content

Commit 7cfc9d0

Browse files
committed
review feedback
1 parent f1ea1f7 commit 7cfc9d0

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"tempy": "^1.0.0",
8383
"ts-node": "^10.5.0",
8484
"tstyche": "^1.0.0-beta.9",
85-
"typescript": "^5.2.2",
85+
"typescript": "^5.0.4",
8686
"webpack": "^5.68.0",
8787
"webpack-node-externals": "^3.0.0",
8888
"which": "^4.0.0"

packages/jest-mock/src/__tests__/index.test.ts

+21-18
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import * as util from 'util';
1212
import {type Context, createContext, runInContext, runInNewContext} from 'vm';
13+
import {onNodeVersions} from '@jest/test-utils';
1314
import {ModuleMocker, fn, mocked, spyOn} from '../';
1415

1516
if (!Symbol.dispose) {
@@ -2441,25 +2442,27 @@ test('`fn` and `spyOn` do not throw', () => {
24412442
}).not.toThrow();
24422443
});
24432444

2444-
describe('Explicit Resource Management', () => {
2445-
it('jest.fn state should be restored with the `using` keyword', () => {
2446-
const mock = jest.fn();
2447-
{
2448-
using inScope = mock.mockReturnValue(2);
2449-
expect(inScope()).toBe(2);
2450-
expect(mock()).toBe(2);
2451-
}
2452-
expect(mock()).not.toBe(2);
2453-
});
2445+
onNodeVersions('>=18.0.0', () => {
2446+
describe('Explicit Resource Management', () => {
2447+
it('jest.fn state should be restored with the `using` keyword', () => {
2448+
const mock = jest.fn();
2449+
{
2450+
using inScope = mock.mockReturnValue(2);
2451+
expect(inScope()).toBe(2);
2452+
expect(mock()).toBe(2);
2453+
}
2454+
expect(mock()).not.toBe(2);
2455+
});
24542456

2455-
it('should be restored with the `using` keyword', () => {
2456-
{
2457-
using mockedLog = jest.spyOn(console, 'log');
2458-
expect(jest.isMockFunction(console.log)).toBeTruthy();
2457+
it('should be restored with the `using` keyword', () => {
2458+
{
2459+
using mockedLog = jest.spyOn(console, 'log');
2460+
expect(jest.isMockFunction(console.log)).toBeTruthy();
24592461

2460-
console.log('test');
2461-
expect(mockedLog).toHaveBeenCalled();
2462-
}
2463-
expect(jest.isMockFunction(console.log)).toBeFalsy();
2462+
console.log('test');
2463+
expect(mockedLog).toHaveBeenCalled();
2464+
}
2465+
expect(jest.isMockFunction(console.log)).toBeFalsy();
2466+
});
24642467
});
24652468
});

packages/jest-mock/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"rootDir": "src",
5-
"outDir": "build"
5+
"outDir": "build",
6+
"lib": ["es2021", "ESNext.Disposable"]
67
},
78
"include": ["./src/**/*"],
89
"exclude": ["./**/__tests__/**/*"],

tsconfig.json

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"declaration": true,
99
"emitDeclarationOnly": true,
1010
"stripInternal": true,
11-
"lib": ["es2021", "ESNext.Disposable"],
1211

1312
"strict": true,
1413

0 commit comments

Comments
 (0)