Skip to content

Commit 5979fa4

Browse files
internal: Jest prep (#3509)
* pkg: Update validation packages to v30 * internal: jest 30 upgrades * internal: Revert jest package updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent d826b94 commit 5979fa4

32 files changed

+97
-104
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989
"eslint": "9.28.0",
9090
"globals": "^16.0.0",
9191
"ignore-styles": "^5.0.1",
92-
"jest": "29.7.0",
93-
"jest-environment-jsdom": "29.7.0",
92+
"jest": "^29",
93+
"jest-environment-jsdom": "^29",
9494
"mkdirp": "^3.0.0",
9595
"nock": "13.3.1",
9696
"node-fetch": "^3.3.0",

packages/core/src/manager/__tests__/pollingSubscription.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Endpoint } from '@data-client/endpoint';
2-
import { Article, PollingArticleResource } from '__tests__/new';
2+
import { Article } from '__tests__/new';
33

44
import { createSubscription } from '../../controller/actions/createSubscription';
55
import Controller from '../../controller/Controller';
@@ -284,13 +284,13 @@ describe('PollingSubscription', () => {
284284
});
285285

286286
describe('cleanup()', () => {
287-
let warnSpy: jest.SpyInstance;
287+
let warnSpy: jest.Spied<typeof console.warn>;
288288
afterEach(() => {
289289
warnSpy.mockRestore();
290290
});
291-
beforeEach(() =>
292-
(warnSpy = jest.spyOn(console, 'warn')).mockImplementation(() => {}),
293-
);
291+
beforeEach(() => {
292+
(warnSpy = jest.spyOn(console, 'warn')).mockImplementation(() => {});
293+
});
294294

295295
it('should stop all timers', () => {
296296
dispatch.mockClear();

packages/core/src/state/__tests__/reducer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ describe('reducer', () => {
638638
expect(newState).toBe(iniState);
639639
});
640640
describe('RESET', () => {
641-
let warnspy: jest.SpyInstance;
641+
let warnspy: jest.Spied<any>;
642642
beforeEach(() => {
643643
warnspy = jest.spyOn(global.console, 'warn').mockImplementation(() => {});
644644
});

packages/endpoint/src/__tests__/endpoint.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ describe.each([true, false])(`Endpoint (CSP %s)`, mockCSP => {
7979
});
8080

8181
describe('Function', () => {
82-
let errorSpy: jest.SpyInstance;
82+
let errorSpy: jest.Spied<typeof console.error>;
8383
afterEach(() => {
8484
errorSpy.mockRestore();
8585
});
86-
beforeEach(
87-
() => (errorSpy = jest.spyOn(console, 'error').mockImplementation()),
88-
);
86+
beforeEach(() => {
87+
errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); // Suppress console.error
88+
});
8989

9090
it('should work when called as function', async () => {
9191
const UserDetail = new Endpoint(fetchUsers);

packages/endpoint/src/__tests__/validateRequired.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// eslint-env jest
2+
import { jest, describe, beforeAll, afterAll, it, expect } from '@jest/globals';
23
import { Temporal } from '@js-temporal/polyfill';
34
import { IDEntity } from '__tests__/new';
45

56
import SimpleMemoCache from '../schemas/__tests__/denormalize';
67
import Entity from '../schemas/Entity';
78
import validateRequired from '../validateRequired';
89

9-
let dateSpy: jest.SpyInstance;
10+
let dateSpy: jest.Spied<any>;
1011
beforeAll(() => {
1112
dateSpy = jest
1213

packages/endpoint/src/schemas/__tests__/All.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// eslint-env jest
21
import { initialState, State, Controller } from '@data-client/core';
32
import {
43
normalize,
@@ -16,7 +15,7 @@ import { IDEntity } from '__tests__/new';
1615
import { schema } from '../..';
1716
import { fromJSState } from './denormalize';
1817

19-
let dateSpy: jest.SpyInstance<number, []>;
18+
let dateSpy: jest.Spied<typeof Date.now>;
2019
beforeAll(() => {
2120
dateSpy = jest
2221

packages/endpoint/src/schemas/__tests__/Collection.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { PolymorphicInterface } from '../..';
99
import { schema } from '../..';
1010
import PolymorphicSchema from '../Polymorphic';
1111

12-
let dateSpy: jest.SpyInstance;
12+
let dateSpy: jest.Spied<any>;
1313
beforeAll(() => {
1414
dateSpy = jest
1515
.spyOn(global.Date, 'now')
@@ -91,13 +91,13 @@ test('key works with custom schema', () => {
9191
});
9292

9393
describe(`${schema.Collection.name} normalization`, () => {
94-
let warnSpy: jest.SpyInstance;
94+
let warnSpy: jest.Spied<typeof console.warn>;
9595
afterEach(() => {
9696
warnSpy.mockRestore();
9797
});
98-
beforeEach(() =>
99-
(warnSpy = jest.spyOn(console, 'warn')).mockImplementation(() => {}),
100-
);
98+
beforeEach(() => {
99+
(warnSpy = jest.spyOn(console, 'warn')).mockImplementation(() => {});
100+
});
101101

102102
test('should throw a custom error if data loads with string unexpected value', () => {
103103
function normalizeBad() {

packages/endpoint/src/schemas/__tests__/Entity.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// eslint-env jest
21
import { normalize, INVALID } from '@data-client/normalizr';
32
import { denormalize as plainDenormalize } from '@data-client/normalizr';
43
import { denormalize as immDenormalize } from '@data-client/normalizr/imm';
@@ -10,7 +9,7 @@ import { AbstractInstanceType } from '../../';
109
import { schema } from '../../';
1110
import Entity from '../Entity';
1211

13-
let dateSpy: jest.SpyInstance;
12+
let dateSpy: jest.Spied<any>;
1413
beforeAll(() => {
1514
dateSpy = jest
1615

@@ -49,13 +48,13 @@ class WithOptional extends Entity {
4948
}
5049

5150
describe(`${Entity.name} normalization`, () => {
52-
let warnSpy: jest.SpyInstance;
51+
let warnSpy: jest.Spied<typeof console.warn>;
5352
afterEach(() => {
5453
warnSpy.mockRestore();
5554
});
56-
beforeEach(() =>
57-
(warnSpy = jest.spyOn(console, 'warn')).mockImplementation(() => {}),
58-
);
55+
beforeEach(() => {
56+
(warnSpy = jest.spyOn(console, 'warn')).mockImplementation(() => {});
57+
});
5958

6059
test('normalizes an entity', () => {
6160
class MyEntity extends Entity {}

packages/endpoint/src/schemas/__tests__/EntityMixin.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Temporal } from '@js-temporal/polyfill';
77
import { SimpleMemoCache, fromJSEntities } from './denormalize';
88
import { schema, EntityMixin } from '../..';
99

10-
let dateSpy: jest.SpyInstance;
10+
let dateSpy: jest.Spied<any>;
1111
beforeAll(() => {
1212
dateSpy = jest
1313

@@ -299,13 +299,13 @@ describe(`${schema.Entity.name} construction`, () => {
299299
});
300300

301301
describe(`${schema.Entity.name} normalization`, () => {
302-
let warnSpy: jest.SpyInstance;
302+
let warnSpy: jest.Spied<typeof console.warn>;
303303
afterEach(() => {
304304
warnSpy.mockRestore();
305305
});
306-
beforeEach(() =>
307-
(warnSpy = jest.spyOn(console, 'warn')).mockImplementation(() => {}),
308-
);
306+
beforeEach(() => {
307+
warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
308+
});
309309

310310
test('normalizes an entity', () => {
311311
class MyEntity extends EntityMixin(IDData) {}

packages/endpoint/src/schemas/__tests__/Invalidate.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import SimpleMemoCache, { fromJSEntities } from './denormalize';
1313
import { schema } from '../..';
1414
import Entity from '../Entity';
1515

16-
let dateSpy: jest.SpyInstance;
16+
let dateSpy: jest.Spied<any>;
1717
beforeAll(() => {
1818
dateSpy = jest
1919
.spyOn(global.Date, 'now')

0 commit comments

Comments
 (0)