Skip to content

Commit eeb5144

Browse files
author
Tommy Markley
committed
Upgrades jest to v27
* Upgrades `jest` from v26.4.2 to v27.5.1. * [CHANGELOG](https://github.com/facebook/jest/blob/v27.5.1/CHANGELOG.md) * v27 introduces breaking changes that have to be addressed. * Upgrades testing-related dependencies, removes unused dependency `babel-plugin-istanbul`, and replaces `jest-environment-jsdom-thirteen` with the built-in `jest-environment-jsdom`. This is a prerequisite to resolving #1231 Signed-off-by: Tommy Markley <[email protected]>
1 parent 8951429 commit eeb5144

File tree

57 files changed

+1841
-2385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1841
-2385
lines changed

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ module.exports = {
542542
{
543543
files: ['**/*.test.{js,mjs,ts,tsx}'],
544544
rules: {
545-
'jest/valid-describe': 'error',
545+
'jest/valid-describe-callback': 'error',
546546
},
547547
},
548548

package.json

+18-21
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
"@types/yauzl": "^2.9.1",
136136
"JSONStream": "1.3.5",
137137
"abortcontroller-polyfill": "^1.4.0",
138-
"angular": "^1.8.0",
138+
"angular": "^1.8.2",
139139
"angular-elastic": "^2.5.1",
140140
"angular-sanitize": "^1.8.0",
141141
"bluebird": "3.5.5",
@@ -233,12 +233,12 @@
233233
"@osd/utility-types": "1.0.0",
234234
"@percy/cli": "^1.0.0-beta.74",
235235
"@percy/sdk-utils": "^1.0.0-beta.74",
236-
"@testing-library/dom": "^7.24.2",
237-
"@testing-library/jest-dom": "^5.11.4",
238-
"@testing-library/react": "^11.0.4",
239-
"@testing-library/react-hooks": "^3.4.1",
240-
"@types/angular": "^1.6.56",
241-
"@types/angular-mocks": "^1.7.0",
236+
"@testing-library/dom": "^8.11.3",
237+
"@testing-library/jest-dom": "^5.16.2",
238+
"@testing-library/react": "^12.1.2",
239+
"@testing-library/react-hooks": "^7.0.2",
240+
"@types/angular": "^1.8.4",
241+
"@types/angular-mocks": "^1.7.1",
242242
"@types/archiver": "^3.1.0",
243243
"@types/babel__core": "^7.1.17",
244244
"@types/bluebird": "^3.1.1",
@@ -267,7 +267,7 @@
267267
"@types/has-ansi": "^3.0.0",
268268
"@types/history": "^4.7.3",
269269
"@types/hjson": "^2.4.2",
270-
"@types/jest": "^26.0.14",
270+
"@types/jest": "^27.4.0",
271271
"@types/joi": "^13.4.2",
272272
"@types/jquery": "^3.3.31",
273273
"@types/js-yaml": "^3.11.1",
@@ -304,12 +304,11 @@
304304
"@types/sinon": "^7.0.13",
305305
"@types/strip-ansi": "^5.2.1",
306306
"@types/styled-components": "^5.1.19",
307-
"@types/supertest": "^2.0.5",
307+
"@types/supertest": "^2.0.11",
308308
"@types/supertest-as-promised": "^2.0.38",
309309
"@types/tapable": "^1.0.6",
310310
"@types/tar": "^4.0.3",
311-
"@types/testing-library__jest-dom": "^5.9.3",
312-
"@types/testing-library__react-hooks": "^3.4.0",
311+
"@types/testing-library__jest-dom": "^5.14.2",
313312
"@types/tough-cookie": "^4.0.1",
314313
"@types/type-detect": "^4.0.1",
315314
"@types/uuid": "^3.4.4",
@@ -321,15 +320,14 @@
321320
"@typescript-eslint/eslint-plugin": "^3.10.0",
322321
"@typescript-eslint/parser": "^3.10.0",
323322
"angular-aria": "^1.8.0",
324-
"angular-mocks": "^1.7.9",
323+
"angular-mocks": "^1.8.2",
325324
"angular-recursion": "^1.0.5",
326325
"angular-route": "^1.8.0",
327326
"angular-sortable-view": "^0.0.17",
328327
"archiver": "^3.1.1",
329328
"axe-core": "^4.0.2",
330329
"babel-eslint": "^10.0.3",
331-
"babel-jest": "^26.3.0",
332-
"babel-plugin-istanbul": "^6.0.0",
330+
"babel-jest": "^27.5.1",
333331
"brace": "0.11.1",
334332
"chai": "3.5.0",
335333
"chance": "1.0.18",
@@ -350,8 +348,8 @@
350348
"eslint-plugin-ban": "^1.4.0",
351349
"eslint-plugin-cypress": "^2.8.1",
352350
"eslint-plugin-eslint-comments": "^3.2.0",
353-
"eslint-plugin-import": "^2.19.1",
354-
"eslint-plugin-jest": "^24.0.2",
351+
"eslint-plugin-import": "^2.25.4",
352+
"eslint-plugin-jest": "^26.1.1",
355353
"eslint-plugin-jsx-a11y": "^6.2.3",
356354
"eslint-plugin-mocha": "^6.2.2",
357355
"eslint-plugin-no-unsanitized": "^3.0.2",
@@ -378,9 +376,8 @@
378376
"history": "^4.9.0",
379377
"immer": "^9.0.6",
380378
"intl-messageformat-parser": "^1.4.0",
381-
"jest": "^26.4.2",
382-
"jest-canvas-mock": "^2.2.0",
383-
"jest-environment-jsdom-thirteen": "^1.0.1",
379+
"jest": "^27.5.1",
380+
"jest-canvas-mock": "^2.3.1",
384381
"jest-raw-loader": "^1.0.1",
385382
"jimp": "^0.14.0",
386383
"jquery": "^3.5.0",
@@ -406,7 +403,7 @@
406403
"ngreact": "^0.5.1",
407404
"nock": "12.0.3",
408405
"normalize-path": "^3.0.0",
409-
"nyc": "^14.1.1",
406+
"nyc": "^15.1.0",
410407
"pixelmatch": "^5.1.0",
411408
"pngjs": "^3.4.0",
412409
"postcss": "^8.4.5",
@@ -431,7 +428,7 @@
431428
"simple-git": "1.116.0",
432429
"sinon": "^7.4.2",
433430
"strip-ansi": "^6.0.0",
434-
"supertest": "^3.1.0",
431+
"supertest": "^6.2.2",
435432
"supertest-as-promised": "^4.0.2",
436433
"tape": "^5.0.1",
437434
"topojson-client": "3.0.0",

packages/opensearch-eslint-config-opensearch-dashboards/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"eslint-plugin-ban": "^1.4.0",
2727
"eslint-plugin-jsx-a11y": "^6.2.3",
2828
"eslint-plugin-eslint-comments": "^3.2.0",
29-
"eslint-plugin-import": "^2.19.1",
30-
"eslint-plugin-jest": "^24.0.2",
29+
"eslint-plugin-import": "^2.25.4",
30+
"eslint-plugin-jest": "^26.1.1",
3131
"eslint-plugin-mocha": "^6.2.2",
3232
"eslint-plugin-no-unsanitized": "^3.0.2",
3333
"eslint-plugin-prefer-object-spread": "^1.2.1",

packages/osd-optimizer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"del": "^5.1.0",
2828
"execa": "^4.0.2",
2929
"file-loader": "^4.2.0",
30-
"jest-diff": "^26.4.2",
30+
"jest-diff": "^27.5.1",
3131
"js-yaml": "^3.14.0",
3232
"json-stable-stringify": "^1.0.1",
3333
"lmdb-store": "^1.6.11",

packages/osd-optimizer/src/optimizer/cache_keys.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
import Path from 'path';
3434

35-
import jestDiff from 'jest-diff';
35+
import { diff } from 'jest-diff';
3636
import { REPO_ROOT } from '@osd/utils';
3737
import { createAbsolutePathSerializer } from '@osd/dev-utils';
3838

@@ -187,7 +187,7 @@ describe('diffCacheKey()', () => {
187187

188188
describe('reformatJestDiff()', () => {
189189
it('reformats large jestDiff output to focus on the changed lines', () => {
190-
const diff = jestDiff(
190+
const jestDiff = diff(
191191
{
192192
a: ['1', '1', '1', '1', '1', '1', '1', '2', '1', '1', '1', '1', '1', '1', '1', '1', '1'],
193193
},
@@ -196,7 +196,7 @@ describe('reformatJestDiff()', () => {
196196
}
197197
);
198198

199-
expect(reformatJestDiff(diff)).toMatchInlineSnapshot(`
199+
expect(reformatJestDiff(jestDiff)).toMatchInlineSnapshot(`
200200
"- Expected
201201
+ Received
202202

packages/osd-optimizer/src/optimizer/cache_keys.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import execa from 'execa';
3939
import { REPO_ROOT } from '@osd/utils';
4040
import stripAnsi from 'strip-ansi';
4141

42-
import jestDiff from 'jest-diff';
42+
import { diff } from 'jest-diff';
4343
import jsonStable from 'json-stable-stringify';
4444
import { ascending, CacheableWorkerConfig } from '../common';
4545

@@ -62,11 +62,11 @@ export function diffCacheKey(expected?: unknown, actual?: unknown) {
6262
return;
6363
}
6464

65-
return reformatJestDiff(jestDiff(expectedJson, actualJson));
65+
return reformatJestDiff(diff(expectedJson, actualJson));
6666
}
6767

68-
export function reformatJestDiff(diff: string | null) {
69-
const diffLines = diff?.split('\n') || [];
68+
export function reformatJestDiff(jestDiff: string | null) {
69+
const diffLines = jestDiff?.split('\n') || [];
7070

7171
if (
7272
diffLines.length < 4 ||

packages/osd-optimizer/src/optimizer/optimizer_config.test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,10 @@ describe('OptimizerConfig::create()', () => {
465465
"invocationCallOrder": Array [
466466
21,
467467
],
468+
"lastCall": Array [
469+
Symbol(parsed plugin scan dirs),
470+
Symbol(parsed plugin paths),
471+
],
468472
"results": Array [
469473
Object {
470474
"type": "return",
@@ -491,6 +495,13 @@ describe('OptimizerConfig::create()', () => {
491495
"invocationCallOrder": Array [
492496
23,
493497
],
498+
"lastCall": Array [
499+
Array [],
500+
Array [
501+
Symbol(bundle1),
502+
Symbol(bundle2),
503+
],
504+
],
494505
"results": Array [
495506
Object {
496507
"type": "return",
@@ -515,6 +526,11 @@ describe('OptimizerConfig::create()', () => {
515526
"invocationCallOrder": Array [
516527
22,
517528
],
529+
"lastCall": Array [
530+
Symbol(new platform plugins),
531+
Symbol(parsed repo root),
532+
Symbol(parsed output root),
533+
],
518534
"results": Array [
519535
Object {
520536
"type": "return",

packages/osd-spec-to-console/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"homepage": "https://github.com/jbudz/spec-to-console#readme",
2222
"devDependencies": {
23-
"jest": "^26.4.2",
23+
"jest": "^27.5.1",
2424
"prettier": "^2.1.1"
2525
},
2626
"dependencies": {

packages/osd-ui-shared-deps/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@osd/i18n": "1.0.0",
1616
"@osd/monaco": "1.0.0",
1717
"abortcontroller-polyfill": "^1.4.0",
18-
"angular": "^1.8.0",
18+
"angular": "^1.8.2",
1919
"axios": "^0.21.4",
2020
"compression-webpack-plugin": "^4.0.0",
2121
"core-js": "^3.6.5",

src/core/TESTING.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -783,17 +783,15 @@ describe('saved query service', () => {
783783
expect(response).toBe(mockReturnValue);
784784
});
785785

786-
it('should reject with an error when saved objects client errors', async (done) => {
786+
it('should reject with an error when saved objects client errors', (done) => {
787787
mockSavedObjectsClient.create.mockRejectedValue(new Error('timeout'));
788788

789-
try {
790-
await savedQueryService.saveQuery(savedQueryAttributes);
791-
} catch (err) {
789+
savedQueryService.saveQuery(savedQueryAttributes).catch((err) => {
792790
expect(err).toMatchInlineSnapshot(
793791
`[Error: Unable to create saved query, please try again.]`
794792
);
795793
done();
796-
}
794+
});
797795
});
798796
});
799797
});

src/core/public/plugins/plugins_service.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*/
3232

3333
import { omit, pick } from 'lodash';
34+
import { setImmediate } from 'timers';
3435

3536
import {
3637
MockedPluginInitializer,
@@ -268,7 +269,8 @@ describe('PluginsService', () => {
268269
describe('timeout', () => {
269270
const flushPromises = () => new Promise((resolve) => setImmediate(resolve));
270271
beforeAll(() => {
271-
jest.useFakeTimers();
272+
jest.useFakeTimers('legacy');
273+
setImmediate(() => {});
272274
});
273275
afterAll(() => {
274276
jest.useRealTimers();

0 commit comments

Comments
 (0)