From 23acc767583055f0b46ad473ed4b4562d5caeea7 Mon Sep 17 00:00:00 2001 From: anlyyao Date: Thu, 9 Feb 2023 11:30:26 +0800 Subject: [PATCH 1/2] test: update jest.virtualHost.config.js --- jest.virtualHost.config.js | 1 + script/test/snapshotResolver.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 script/test/snapshotResolver.js diff --git a/jest.virtualHost.config.js b/jest.virtualHost.config.js index 859cf70d9..1f25661ea 100644 --- a/jest.virtualHost.config.js +++ b/jest.virtualHost.config.js @@ -33,4 +33,5 @@ module.exports = { }, globalSetup: '/script/test/globalSetup.js', snapshotSerializers: ['miniprogram-simulate/jest-snapshot-plugin'], + snapshotResolver: '/script/test/snapshotResolver.js', }; diff --git a/script/test/snapshotResolver.js b/script/test/snapshotResolver.js new file mode 100644 index 000000000..47664f502 --- /dev/null +++ b/script/test/snapshotResolver.js @@ -0,0 +1,12 @@ +module.exports = { + // resolves from test to snapshot path + resolveSnapshotPath: (testPath, snapshotExtension) => + testPath.replace('__test__', '__test__/__virtualHostSnapshot__') + snapshotExtension, + + // resolves from snapshot to test path + resolveTestPath: (snapshotFilePath, snapshotExtension) => + snapshotFilePath.replace('__test__/__virtualHostSnapshot__', '__test__').slice(0, -snapshotExtension.length), + + // Example test path, used for preflight consistency check of the implementation above + testPathForConsistencyCheck: 'some/__tests__/example.test.js', +}; From 326b11a2464882226f6615e821aeecf02f650d54 Mon Sep 17 00:00:00 2001 From: anlyyao Date: Thu, 9 Feb 2023 11:30:58 +0800 Subject: [PATCH 2/2] test: update snapshots for avatar --- .../__test__/__snapshots__/index.test.js.snap | 46 ++++ .../__virtualHostSnapshot__/demo.test.js.snap | 229 ++++++++++++++++++ .../index.test.js.snap | 46 ++++ src/avatar/__test__/index.test.js | 2 +- 4 files changed, 322 insertions(+), 1 deletion(-) create mode 100644 src/avatar/__test__/__snapshots__/index.test.js.snap create mode 100644 src/avatar/__test__/__virtualHostSnapshot__/demo.test.js.snap create mode 100644 src/avatar/__test__/__virtualHostSnapshot__/index.test.js.snap diff --git a/src/avatar/__test__/__snapshots__/index.test.js.snap b/src/avatar/__test__/__snapshots__/index.test.js.snap new file mode 100644 index 000000000..c581813b4 --- /dev/null +++ b/src/avatar/__test__/__snapshots__/index.test.js.snap @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Avatar & Avatar Groups Avatar Props : style && customStyle 1`] = ` +
+
+ + + + + + + + + + + +
+
+`; diff --git a/src/avatar/__test__/__virtualHostSnapshot__/demo.test.js.snap b/src/avatar/__test__/__virtualHostSnapshot__/demo.test.js.snap new file mode 100644 index 000000000..789d390bf --- /dev/null +++ b/src/avatar/__test__/__virtualHostSnapshot__/demo.test.js.snap @@ -0,0 +1,229 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Avatar Avatar action demo works fine 1`] = ` + + + + + + + + + + +`; + +exports[`Avatar Avatar badge-avatar demo works fine 1`] = ` + + + + A + + + +`; + +exports[`Avatar Avatar character-avatar demo works fine 1`] = ` + + + A + + + A + + +`; + +exports[`Avatar Avatar exhibition demo works fine 1`] = ` + + + + + + + + + + +`; + +exports[`Avatar Avatar icon-avatar demo works fine 1`] = ` + + + + +`; + +exports[`Avatar Avatar image-avatar demo works fine 1`] = ` + + + + +`; + +exports[`Avatar Avatar size demo works fine 1`] = ` + + + + + A + + + + + + + A + + + + + + + A + + + + +`; diff --git a/src/avatar/__test__/__virtualHostSnapshot__/index.test.js.snap b/src/avatar/__test__/__virtualHostSnapshot__/index.test.js.snap new file mode 100644 index 000000000..c292c83f6 --- /dev/null +++ b/src/avatar/__test__/__virtualHostSnapshot__/index.test.js.snap @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Avatar & Avatar Groups Avatar Props : style && customStyle 1`] = ` +
+
+ + + + + + + + + + + +
+
+`; diff --git a/src/avatar/__test__/index.test.js b/src/avatar/__test__/index.test.js index ddc353944..17ab8af9d 100644 --- a/src/avatar/__test__/index.test.js +++ b/src/avatar/__test__/index.test.js @@ -22,7 +22,7 @@ describe('Avatar & Avatar Groups', () => { const comp = simulate.render(id); comp.attach(document.createElement('parent-wrapper')); const $avatar = comp.querySelector('.avatar >>> .t-avatar__wrapper'); - // expect(comp.toJSON()).toMatchSnapshot(); + expect(comp.toJSON()).toMatchSnapshot(); if (VIRTUAL_HOST) { expect($avatar.dom.getAttribute('style').includes(`${comp.data.style}; ${comp.data.customStyle}`)).toBeTruthy(); } else {