@shopgate/pwa-unit-test 7.30.0-alpha.8 → 7.30.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/envSetup.js +34 -5
- package/jest.config.js +8 -4
- package/package.json +6 -7
package/envSetup.js
CHANGED
|
@@ -1,16 +1,45 @@
|
|
|
1
|
-
/* global jasmine */
|
|
2
1
|
/* eslint-disable max-len */
|
|
3
2
|
/* eslint-disable require-jsdoc, extra-rules/potential-point-free, class-methods-use-this, no-unused-vars */
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
// Extend Jest matchers to add Enzyme specific ones (necessary since jest-enzyme packages was dropped)
|
|
5
|
+
expect.extend({
|
|
6
|
+
toBeEmptyRender(received) {
|
|
7
|
+
const isFn = fn => typeof fn === 'function';
|
|
8
|
+
|
|
9
|
+
// Prefer Enzyme's API when available (shallow)
|
|
10
|
+
let empty =
|
|
11
|
+
isFn(received.isEmptyRender) ? received.isEmptyRender() : null;
|
|
12
|
+
|
|
13
|
+
// Fallback: try to infer from HTML (mount / generic wrappers)
|
|
14
|
+
if (empty === null) {
|
|
15
|
+
const html = isFn(received.html) ? received.html() : undefined;
|
|
16
|
+
empty = html == null || /^\s*$/.test(String(html));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const pass = empty === true;
|
|
20
|
+
return {
|
|
21
|
+
pass,
|
|
22
|
+
message: () =>
|
|
23
|
+
(pass
|
|
24
|
+
? 'expected wrapper NOT to be an empty render'
|
|
25
|
+
: 'expected wrapper to be an empty render'),
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
toExist(received) {
|
|
29
|
+
const pass = typeof received.exists === 'function' ? received.exists() : !!received.length;
|
|
30
|
+
return {
|
|
31
|
+
pass,
|
|
32
|
+
message: () =>
|
|
33
|
+
(pass ? 'expected wrapper NOT to exist' : 'expected wrapper to exist'),
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
});
|
|
6
37
|
|
|
7
38
|
global.SGEvent = {
|
|
8
39
|
__call: () => { },
|
|
9
40
|
};
|
|
10
41
|
|
|
11
|
-
|
|
12
|
-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
|
13
|
-
}
|
|
42
|
+
jest.setTimeout(10000);
|
|
14
43
|
|
|
15
44
|
global.mutationConstructorSpy = jest.fn();
|
|
16
45
|
global.mutationObserveSpy = jest.fn();
|
package/jest.config.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
/** @type {import('jest').Config} */
|
|
1
2
|
module.exports = {
|
|
3
|
+
testEnvironment: 'jsdom',
|
|
4
|
+
silent: false,
|
|
2
5
|
moduleFileExtensions: ['js', 'jsx', 'json', 'mjs'],
|
|
3
6
|
moduleNameMapper: {
|
|
4
|
-
|
|
7
|
+
// Mock styles since they are not needed for unit tests
|
|
8
|
+
'\\.(css|sass)$': '<rootDir>/__mocks__/styleMock.js',
|
|
5
9
|
// Fix issue with Swiper ES module imports that work via "exports" field in package.json
|
|
6
10
|
'^swiper/react$': '<rootDir>/node_modules/swiper/swiper-react.mjs',
|
|
7
|
-
// Mock Swiper styles since they are not needed for unit tests
|
|
8
|
-
'^swiper/css(?:/.*)?$': '<rootDir>/__mocks__/styleMock.js',
|
|
9
11
|
},
|
|
10
12
|
transform: {
|
|
11
13
|
'^.+\\.jsx?$': 'babel-jest',
|
|
@@ -41,5 +43,7 @@ module.exports = {
|
|
|
41
43
|
setupFilesAfterEnv: [
|
|
42
44
|
'@shopgate/pwa-unit-test/envSetup.js',
|
|
43
45
|
],
|
|
44
|
-
|
|
46
|
+
testEnvironmentOptions: {
|
|
47
|
+
url: 'http://localhost',
|
|
48
|
+
},
|
|
45
49
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-unit-test",
|
|
3
|
-
"version": "7.30.0-alpha.
|
|
3
|
+
"version": "7.30.0-alpha.9",
|
|
4
4
|
"description": "The unit tests setup for Shopgate's ENGAGE.",
|
|
5
5
|
"author": "Shopgate <support@shopgate.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -8,22 +8,21 @@
|
|
|
8
8
|
"cheerio": "1.0.0-rc.2",
|
|
9
9
|
"enzyme": "^3.11.0",
|
|
10
10
|
"enzyme-adapter-react-16": "^1.15.8",
|
|
11
|
-
"enzyme-to-json": "^3.6.2"
|
|
12
|
-
"identity-obj-proxy": "~3.0.0",
|
|
13
|
-
"jest-enzyme": "^7.1.2"
|
|
11
|
+
"enzyme-to-json": "^3.6.2"
|
|
14
12
|
},
|
|
15
13
|
"devDependencies": {
|
|
16
14
|
"@babel/core": "^7.28.5",
|
|
17
15
|
"@babel/preset-env": "^7.28.5",
|
|
18
16
|
"@babel/preset-react": "^7.28.5",
|
|
19
17
|
"@types/enzyme": "^3.10.18",
|
|
20
|
-
"babel-jest": "^
|
|
21
|
-
"jest": "^
|
|
18
|
+
"babel-jest": "^29.7.0",
|
|
19
|
+
"jest": "^29.7.0",
|
|
20
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
22
21
|
"react": "~16.14.0",
|
|
23
22
|
"react-dom": "~16.14.0"
|
|
24
23
|
},
|
|
25
24
|
"peerDependencies": {
|
|
26
|
-
"jest": "^
|
|
25
|
+
"jest": "^29.7.0",
|
|
27
26
|
"react": "~16.14.0",
|
|
28
27
|
"react-dom": "~16.14.0"
|
|
29
28
|
}
|