Merge pull request #14221 from strapi/chore/jest-29

chore: Update jest packages to v29
This commit is contained in:
Gustav Hansen 2022-08-31 14:40:00 +02:00 committed by GitHub
commit 7f0ddf0654
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1537 additions and 1429 deletions

View File

@ -51,6 +51,7 @@ module.exports = {
'<rootDir>/packages/admin-test-utils/lib/setup/styled-components.js', '<rootDir>/packages/admin-test-utils/lib/setup/styled-components.js',
'<rootDir>/packages/admin-test-utils/lib/setup/strapi.js', '<rootDir>/packages/admin-test-utils/lib/setup/strapi.js',
], ],
testEnvironment: 'jsdom',
transform: { transform: {
'^.+\\.js$': ['@swc/jest', { jsc: { parser: { jsx: true, dynamicImport: true } } }], '^.+\\.js$': ['@swc/jest', { jsc: { parser: { jsx: true, dynamicImport: true } } }],
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':

View File

@ -87,9 +87,10 @@
"husky": "3.1.0", "husky": "3.1.0",
"inquirer": "8.2.4", "inquirer": "8.2.4",
"istanbul": "~0.4.2", "istanbul": "~0.4.2",
"jest": "26.6.3", "jest": "29.0.0",
"jest-circus": "26.6.3", "jest-circus": "29.0.0",
"jest-cli": "26.6.3", "jest-cli": "29.0.0",
"jest-environment-jsdom": "29.0.0",
"jest-watch-typeahead": "0.6.5", "jest-watch-typeahead": "0.6.5",
"lerna": "5.4.3", "lerna": "5.4.3",
"lint-staged": "10.5.4", "lint-staged": "10.5.4",

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@ describe('Configuration settings service', () => {
const settings = await settingsService.createDefaultSettings(schema); const settings = await settingsService.createDefaultSettings(schema);
expect(settings).toMatchInlineSnapshot(` expect(settings).toMatchInlineSnapshot(`
Object { {
"bulkable": true, "bulkable": true,
"defaultSortBy": "id", "defaultSortBy": "id",
"defaultSortOrder": "ASC", "defaultSortOrder": "ASC",

View File

@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Content types service format ContentType Returns consistent schemas 1`] = ` exports[`Content types service format ContentType Returns consistent schemas 1`] = `
Object { {
"apiID": "my-name", "apiID": "my-name",
"plugin": "some-plugin", "plugin": "some-plugin",
"schema": Object { "schema": {
"attributes": Object { "attributes": {
"title": Object { "title": {
"type": "string", "type": "string",
}, },
}, },
@ -15,8 +15,8 @@ Object {
"displayName": "My name", "displayName": "My name",
"draftAndPublish": false, "draftAndPublish": false,
"kind": "singleType", "kind": "singleType",
"pluginOptions": Object { "pluginOptions": {
"content-manager": Object { "content-manager": {
"visible": true, "visible": true,
}, },
}, },

View File

@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Content Type Builder - Content types Collection Types Get collection type returns full schema and information 1`] = ` exports[`Content Type Builder - Content types Collection Types Get collection type returns full schema and information 1`] = `
Object { {
"data": Object { "data": {
"apiID": "test-collection-type", "apiID": "test-collection-type",
"schema": Object { "schema": {
"attributes": Object { "attributes": {
"title": Object { "title": {
"pluginOptions": Object { "pluginOptions": {
"i18n": Object { "i18n": {
"localized": true, "localized": true,
}, },
}, },
@ -20,8 +20,8 @@ Object {
"displayName": "Test Collection Type", "displayName": "Test Collection Type",
"draftAndPublish": false, "draftAndPublish": false,
"kind": "collectionType", "kind": "collectionType",
"pluginOptions": Object { "pluginOptions": {
"i18n": Object { "i18n": {
"localized": true, "localized": true,
}, },
}, },
@ -36,12 +36,12 @@ Object {
`; `;
exports[`Content Type Builder - Content types Collection Types Get collection type returns full schema and informations with draftAndPublish 1`] = ` exports[`Content Type Builder - Content types Collection Types Get collection type returns full schema and informations with draftAndPublish 1`] = `
Object { {
"data": Object { "data": {
"apiID": "ct-with-dp", "apiID": "ct-with-dp",
"schema": Object { "schema": {
"attributes": Object { "attributes": {
"title": Object { "title": {
"type": "string", "type": "string",
}, },
}, },

View File

@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Content Type Builder - Content types Single Types Get single type returns full schema and information 1`] = ` exports[`Content Type Builder - Content types Single Types Get single type returns full schema and information 1`] = `
Object { {
"data": Object { "data": {
"apiID": "test-single-type", "apiID": "test-single-type",
"schema": Object { "schema": {
"attributes": Object { "attributes": {
"title": Object { "title": {
"pluginOptions": Object { "pluginOptions": {
"i18n": Object { "i18n": {
"localized": true, "localized": true,
}, },
}, },
@ -20,8 +20,8 @@ Object {
"displayName": "Test Single Type", "displayName": "Test Single Type",
"draftAndPublish": false, "draftAndPublish": false,
"kind": "singleType", "kind": "singleType",
"pluginOptions": Object { "pluginOptions": {
"i18n": Object { "i18n": {
"localized": true, "localized": true,
}, },
}, },

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`SelectTree renders 1`] = ` exports[`SelectTree renders 1`] = `
Object { {
"asFragment": [Function], "asFragment": [Function],
"baseElement": .c3 { "baseElement": .c3 {
border: 0; border: 0;

View File

@ -1,22 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`flattenTree flattens the passed tree structure properly 1`] = ` exports[`flattenTree flattens the passed tree structure properly 1`] = `
Array [ [
Object { {
"depth": 0, "depth": 0,
"label": "Folder 1", "label": "Folder 1",
"parent": undefined, "parent": undefined,
"value": "f-1", "value": "f-1",
}, },
Object { {
"children": Array [ "children": [
Object { {
"label": "Folder 2-1", "label": "Folder 2-1",
"value": "f-2-1", "value": "f-2-1",
}, },
Object { {
"children": Array [ "children": [
Object { {
"label": "Folder 2-2-1", "label": "Folder 2-2-1",
"value": "f-2-2-1", "value": "f-2-2-1",
}, },
@ -30,15 +30,15 @@ Array [
"parent": undefined, "parent": undefined,
"value": "f-2", "value": "f-2",
}, },
Object { {
"depth": 1, "depth": 1,
"label": "Folder 2-1", "label": "Folder 2-1",
"parent": "f-2", "parent": "f-2",
"value": "f-2-1", "value": "f-2-1",
}, },
Object { {
"children": Array [ "children": [
Object { {
"label": "Folder 2-2-1", "label": "Folder 2-2-1",
"value": "f-2-2-1", "value": "f-2-2-1",
}, },
@ -48,7 +48,7 @@ Array [
"parent": "f-2", "parent": "f-2",
"value": "f-2-2", "value": "f-2-2",
}, },
Object { {
"depth": 2, "depth": 2,
"label": "Folder 2-2-1", "label": "Folder 2-2-1",
"parent": "f-2-2", "parent": "f-2-2",

View File

@ -2,11 +2,6 @@
const metricsService = require('../metrics'); const metricsService = require('../metrics');
// TODO: the matcher exists in jest@28
const closeTo = (expected, precision = 2) => ({
asymmetricMatch: (actual) => Math.abs(expected - actual) < 10 ** -precision / 2,
});
describe('metrics', () => { describe('metrics', () => {
describe('computeMetrics', () => { describe('computeMetrics', () => {
test.each([ test.each([
@ -95,9 +90,9 @@ describe('metrics', () => {
expect(results).toMatchObject({ expect(results).toMatchObject({
assetNumber, assetNumber,
folderNumber, folderNumber,
averageDepth: closeTo(averageDepth, 3), averageDepth: expect.closeTo(averageDepth, 3),
maxDepth, maxDepth,
averageDeviationDepth: closeTo(averageDeviationDepth, 3), averageDeviationDepth: expect.closeTo(averageDeviationDepth, 3),
}); });
}); });
}); });

1377
yarn.lock

File diff suppressed because it is too large Load Diff