Skip to content

Commit 3eafa93

Browse files
committed
Update Jest
1 parent c869e53 commit 3eafa93

File tree

9 files changed

+1782
-2252
lines changed

9 files changed

+1782
-2252
lines changed

jest-disable-built-in-fetch.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = function () {
2+
// This is required for tests to work with "cross-fetch" on newer node versions,
3+
// otherwise "cross-fetch" won't replace the builtin `fetch`
4+
globalThis.fetch = undefined
5+
}

jest.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// @TODO Remove this once merged with eslint updates
2+
// eslint-disable-next-line tsdoc/syntax
3+
/** @type {import('jest').Config} */
14
const config = {
25
rootDir: '.',
36
testMatch: ['<rootDir>/tests/**/*.ts?(x)'],
@@ -15,6 +18,7 @@ const config = {
1518
'jest-watch-typeahead/filename',
1619
'jest-watch-typeahead/testname',
1720
],
21+
globalSetup: './jest-disable-built-in-fetch.js',
1822
projects: [
1923
{
2024
preset: 'ts-jest',

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"@rollup/plugin-commonjs": "25.0.2",
7979
"@rollup/plugin-json": "^6.0.0",
8080
"@rollup/plugin-node-resolve": "15.1.0",
81-
"@types/jest": "^27.5.0",
81+
"@types/jest": "^29.5.11",
8282
"@types/prettier": "^2.2.3",
8383
"@typescript-eslint/eslint-plugin": "2.34.0",
8484
"@typescript-eslint/parser": "2.34.0",
@@ -88,16 +88,17 @@
8888
"eslint-config-prettier": "^8.1.0",
8989
"eslint-config-standard-with-typescript": "^17.0.0",
9090
"eslint-plugin-import": "2",
91-
"eslint-plugin-jest": "^24.1.8",
91+
"eslint-plugin-jest": "^27.6.1",
9292
"eslint-plugin-node": "11",
9393
"eslint-plugin-prettier": "^3.1.4",
9494
"eslint-plugin-promise": "4",
9595
"eslint-plugin-standard": "5",
9696
"eslint-plugin-tsdoc": "^0.2.17",
9797
"gzip-size": "^6.0.0",
98-
"jest": "^26.6.3",
98+
"jest": "^29.7.0",
99+
"jest-environment-jsdom": "^29.7.0",
99100
"jest-fetch-mock": "^3.0.3",
100-
"jest-watch-typeahead": "^0.6.3",
101+
"jest-watch-typeahead": "^2.2.2",
101102
"kleur": "^4.1.5",
102103
"lint-staged": "11.1.2",
103104
"nodemon": "^2.0.16",
@@ -108,7 +109,7 @@
108109
"rollup-plugin-terser": "^7.0.0",
109110
"rollup-plugin-typescript2": "^0.35.0",
110111
"shx": "^0.3.2",
111-
"ts-jest": "^26.5.6",
112+
"ts-jest": "^29.1.1",
112113
"typescript": "^4.9.5"
113114
}
114115
}

tests/__snapshots__/facet_search.test.ts.snap

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Test on POST search Admin key: basic facet value search 1`] = `
4-
Object {
5-
"facetHits": Array [
6-
Object {
4+
{
5+
"facetHits": [
6+
{
77
"count": 1,
88
"value": "action",
99
},
10-
Object {
10+
{
1111
"count": 2,
1212
"value": "adventure",
1313
},
@@ -18,9 +18,9 @@ Object {
1818
`;
1919

2020
exports[`Test on POST search Admin key: facet value search with filter 1`] = `
21-
Object {
22-
"facetHits": Array [
23-
Object {
21+
{
22+
"facetHits": [
23+
{
2424
"count": 1,
2525
"value": "action",
2626
},
@@ -31,21 +31,21 @@ Object {
3131
`;
3232

3333
exports[`Test on POST search Admin key: facet value search with no facet query 1`] = `
34-
Object {
35-
"facetHits": Array [
36-
Object {
34+
{
35+
"facetHits": [
36+
{
3737
"count": 1,
3838
"value": "action",
3939
},
40-
Object {
40+
{
4141
"count": 2,
4242
"value": "adventure",
4343
},
44-
Object {
44+
{
4545
"count": 1,
4646
"value": "comedy",
4747
},
48-
Object {
48+
{
4949
"count": 2,
5050
"value": "romance",
5151
},
@@ -56,9 +56,9 @@ Object {
5656
`;
5757

5858
exports[`Test on POST search Admin key: facet value search with search query 1`] = `
59-
Object {
60-
"facetHits": Array [
61-
Object {
59+
{
60+
"facetHits": [
61+
{
6262
"count": 1,
6363
"value": "adventure",
6464
},
@@ -69,13 +69,13 @@ Object {
6969
`;
7070

7171
exports[`Test on POST search Master key: basic facet value search 1`] = `
72-
Object {
73-
"facetHits": Array [
74-
Object {
72+
{
73+
"facetHits": [
74+
{
7575
"count": 1,
7676
"value": "action",
7777
},
78-
Object {
78+
{
7979
"count": 2,
8080
"value": "adventure",
8181
},
@@ -86,9 +86,9 @@ Object {
8686
`;
8787

8888
exports[`Test on POST search Master key: facet value search with filter 1`] = `
89-
Object {
90-
"facetHits": Array [
91-
Object {
89+
{
90+
"facetHits": [
91+
{
9292
"count": 1,
9393
"value": "action",
9494
},
@@ -99,21 +99,21 @@ Object {
9999
`;
100100

101101
exports[`Test on POST search Master key: facet value search with no facet query 1`] = `
102-
Object {
103-
"facetHits": Array [
104-
Object {
102+
{
103+
"facetHits": [
104+
{
105105
"count": 1,
106106
"value": "action",
107107
},
108-
Object {
108+
{
109109
"count": 2,
110110
"value": "adventure",
111111
},
112-
Object {
112+
{
113113
"count": 1,
114114
"value": "comedy",
115115
},
116-
Object {
116+
{
117117
"count": 2,
118118
"value": "romance",
119119
},
@@ -124,9 +124,9 @@ Object {
124124
`;
125125

126126
exports[`Test on POST search Master key: facet value search with search query 1`] = `
127-
Object {
128-
"facetHits": Array [
129-
Object {
127+
{
128+
"facetHits": [
129+
{
130130
"count": 1,
131131
"value": "adventure",
132132
},
@@ -137,13 +137,13 @@ Object {
137137
`;
138138

139139
exports[`Test on POST search Search key: basic facet value search 1`] = `
140-
Object {
141-
"facetHits": Array [
142-
Object {
140+
{
141+
"facetHits": [
142+
{
143143
"count": 1,
144144
"value": "action",
145145
},
146-
Object {
146+
{
147147
"count": 2,
148148
"value": "adventure",
149149
},
@@ -154,9 +154,9 @@ Object {
154154
`;
155155

156156
exports[`Test on POST search Search key: facet value search with filter 1`] = `
157-
Object {
158-
"facetHits": Array [
159-
Object {
157+
{
158+
"facetHits": [
159+
{
160160
"count": 1,
161161
"value": "action",
162162
},
@@ -167,21 +167,21 @@ Object {
167167
`;
168168

169169
exports[`Test on POST search Search key: facet value search with no facet query 1`] = `
170-
Object {
171-
"facetHits": Array [
172-
Object {
170+
{
171+
"facetHits": [
172+
{
173173
"count": 1,
174174
"value": "action",
175175
},
176-
Object {
176+
{
177177
"count": 2,
178178
"value": "adventure",
179179
},
180-
Object {
180+
{
181181
"count": 1,
182182
"value": "comedy",
183183
},
184-
Object {
184+
{
185185
"count": 2,
186186
"value": "romance",
187187
},
@@ -192,9 +192,9 @@ Object {
192192
`;
193193

194194
exports[`Test on POST search Search key: facet value search with search query 1`] = `
195-
Object {
196-
"facetHits": Array [
197-
Object {
195+
{
196+
"facetHits": [
197+
{
198198
"count": 1,
199199
"value": "adventure",
200200
},

tests/__snapshots__/faceting.test.ts.snap

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Test on faceting Admin key: Get default faceting object 1`] = `
4-
Object {
4+
{
55
"maxValuesPerFacet": 100,
6-
"sortFacetValuesBy": Object {
6+
"sortFacetValuesBy": {
77
"*": "alpha",
88
},
99
}
1010
`;
1111

1212
exports[`Test on faceting Admin key: Reset faceting 1`] = `
13-
Object {
13+
{
1414
"maxValuesPerFacet": 100,
15-
"sortFacetValuesBy": Object {
15+
"sortFacetValuesBy": {
1616
"*": "alpha",
1717
},
1818
}
1919
`;
2020

2121
exports[`Test on faceting Admin key: Update faceting at null 1`] = `
22-
Object {
22+
{
2323
"maxValuesPerFacet": 100,
24-
"sortFacetValuesBy": Object {
24+
"sortFacetValuesBy": {
2525
"*": "alpha",
2626
},
2727
}
2828
`;
2929

3030
exports[`Test on faceting Admin key: Update faceting settings 1`] = `
31-
Object {
31+
{
3232
"maxValuesPerFacet": 12,
33-
"sortFacetValuesBy": Object {
33+
"sortFacetValuesBy": {
3434
"*": "alpha",
3535
"test": "count",
3636
},
3737
}
3838
`;
3939

4040
exports[`Test on faceting Master key: Get default faceting object 1`] = `
41-
Object {
41+
{
4242
"maxValuesPerFacet": 100,
43-
"sortFacetValuesBy": Object {
43+
"sortFacetValuesBy": {
4444
"*": "alpha",
4545
},
4646
}
4747
`;
4848

4949
exports[`Test on faceting Master key: Reset faceting 1`] = `
50-
Object {
50+
{
5151
"maxValuesPerFacet": 100,
52-
"sortFacetValuesBy": Object {
52+
"sortFacetValuesBy": {
5353
"*": "alpha",
5454
},
5555
}
5656
`;
5757

5858
exports[`Test on faceting Master key: Update faceting at null 1`] = `
59-
Object {
59+
{
6060
"maxValuesPerFacet": 100,
61-
"sortFacetValuesBy": Object {
61+
"sortFacetValuesBy": {
6262
"*": "alpha",
6363
},
6464
}
6565
`;
6666

6767
exports[`Test on faceting Master key: Update faceting settings 1`] = `
68-
Object {
68+
{
6969
"maxValuesPerFacet": 12,
70-
"sortFacetValuesBy": Object {
70+
"sortFacetValuesBy": {
7171
"*": "alpha",
7272
"test": "count",
7373
},

0 commit comments

Comments
 (0)