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/strapi.js',
],
testEnvironment: 'jsdom',
transform: {
'^.+\\.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)$':

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -12,16 +12,16 @@ describe('Configuration settings service', () => {
const settings = await settingsService.createDefaultSettings(schema);
expect(settings).toMatchInlineSnapshot(`
Object {
"bulkable": true,
"defaultSortBy": "id",
"defaultSortOrder": "ASC",
"filterable": true,
"mainField": "id",
"pageSize": 10,
"searchable": true,
}
`);
{
"bulkable": true,
"defaultSortBy": "id",
"defaultSortOrder": "ASC",
"filterable": true,
"mainField": "id",
"pageSize": 10,
"searchable": true,
}
`);
});
test('uses id as mainField by default', async () => {

View File

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

View File

@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
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",
"schema": Object {
"attributes": Object {
"title": Object {
"pluginOptions": Object {
"i18n": Object {
"schema": {
"attributes": {
"title": {
"pluginOptions": {
"i18n": {
"localized": true,
},
},
@ -20,8 +20,8 @@ Object {
"displayName": "Test Collection Type",
"draftAndPublish": false,
"kind": "collectionType",
"pluginOptions": Object {
"i18n": Object {
"pluginOptions": {
"i18n": {
"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`] = `
Object {
"data": Object {
{
"data": {
"apiID": "ct-with-dp",
"schema": Object {
"attributes": Object {
"title": Object {
"schema": {
"attributes": {
"title": {
"type": "string",
},
},

View File

@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
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",
"schema": Object {
"attributes": Object {
"title": Object {
"pluginOptions": Object {
"i18n": Object {
"schema": {
"attributes": {
"title": {
"pluginOptions": {
"i18n": {
"localized": true,
},
},
@ -20,8 +20,8 @@ Object {
"displayName": "Test Single Type",
"draftAndPublish": false,
"kind": "singleType",
"pluginOptions": Object {
"i18n": Object {
"pluginOptions": {
"i18n": {
"localized": true,
},
},

View File

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

View File

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

View File

@ -2,11 +2,6 @@
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('computeMetrics', () => {
test.each([
@ -95,9 +90,9 @@ describe('metrics', () => {
expect(results).toMatchObject({
assetNumber,
folderNumber,
averageDepth: closeTo(averageDepth, 3),
averageDepth: expect.closeTo(averageDepth, 3),
maxDepth,
averageDeviationDepth: closeTo(averageDeviationDepth, 3),
averageDeviationDepth: expect.closeTo(averageDeviationDepth, 3),
});
});
});

1377
yarn.lock

File diff suppressed because it is too large Load Diff