@spscommerce/e2e-core 2.2.16 → 2.3.2
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/README.md +1 -3
- package/lib/globalSetup.js +13 -5
- package/lib/globalSetup.js.map +1 -1
- package/lib/globalTeardown.js +6 -2
- package/lib/globalTeardown.js.map +1 -1
- package/package.json +1 -1
- package/playwright.config.js +23 -3
- package/src/globalSetup.ts +15 -5
- package/src/globalTeardown.ts +6 -2
package/README.md
CHANGED
|
@@ -77,9 +77,7 @@ If CI is set to true, the forbidOnly and maxFailures options are applied.
|
|
|
77
77
|
- maxFailures: Stop test suite execution after reaching 5 failed tests and skip any tests that were not executed yet.
|
|
78
78
|
|
|
79
79
|
### Authentication
|
|
80
|
-
Authentication flow was implemented in the e2e-core library. When tests are
|
|
81
|
-
> Attention:
|
|
82
|
-
> While local debugging, the storageState might get expired. User will be redirected to the login page. If it happens, please delete an auth folder in order to invoke an auth state again.
|
|
80
|
+
Authentication flow was implemented in the e2e-core library. When tests are launnhed for the first time, it takes some time for the authentication state to be invoked. If ENV variable is not set, the storageState is created for the test environment, otherwise set URL to 'prod'. After auth state is invoked, it appears in the results-e2e/auth folder. All the next test runs will use an already created storageState.json file.
|
|
83
81
|
|
|
84
82
|
### Global setup
|
|
85
83
|
To set something up once before running all tests, create a JS file and link it via SETUP_PATH variable in the `package.json`. Global setup file must export a single function that runs once before all the tests.
|
package/lib/globalSetup.js
CHANGED
|
@@ -30,7 +30,14 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
30
30
|
const path_1 = __importDefault(require("path"));
|
|
31
31
|
const test_1 = require("@playwright/test");
|
|
32
32
|
const domain = 'commerce.spscommerce.com';
|
|
33
|
-
|
|
33
|
+
let baseUrl = 'https://test.' + domain;
|
|
34
|
+
let storageFile = path_1.default.join(process.cwd(), `results-e2e/auth/storageStateTest.json`);
|
|
35
|
+
let traceFile = path_1.default.join(process.cwd(), 'results-e2e/auth/globalSetupTest.zip');
|
|
36
|
+
if (process.env.ENV && process.env.ENV.includes('prod')) {
|
|
37
|
+
baseUrl = 'https://' + domain;
|
|
38
|
+
storageFile = path_1.default.join(process.cwd(), `results-e2e/auth/storageStateProd.json`);
|
|
39
|
+
traceFile = path_1.default.join(process.cwd(), 'results-e2e/auth/globalSetupProd.zip');
|
|
40
|
+
}
|
|
34
41
|
async function globalSetup() {
|
|
35
42
|
// Remove custom sub-folders for test artifacts
|
|
36
43
|
const resultsFolder = path_1.default.join(process.cwd(), 'results-e2e/');
|
|
@@ -41,10 +48,11 @@ async function globalSetup() {
|
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
|
-
// Launch browser and log in if storageState.json does not exist
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
// Launch browser and log in if storageState.json does not exist OR auth expires soon
|
|
52
|
+
const currentTS = new Date().getTime();
|
|
53
|
+
if (!fs_1.default.existsSync(storageFile) ||
|
|
54
|
+
(fs_1.default.existsSync(storageFile) &&
|
|
55
|
+
((JSON.parse(fs_1.default.readFileSync(storageFile, 'utf8')).origins[0].localStorage.find(o => o.name === 'expires_at').value - currentTS) / 60000) < 30)) {
|
|
48
56
|
const browser = await test_1.chromium.launch({ headless: false }); // { headless: false }
|
|
49
57
|
const context = await browser.newContext();
|
|
50
58
|
await context.tracing.start({ screenshots: true, snapshots: true });
|
package/lib/globalSetup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalSetup.js","sourceRoot":"","sources":["../src/globalSetup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,2CAA4C;AAE5C,MAAM,MAAM,GAAG,0BAA0B,CAAC;AAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,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MAAM,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;YACrC,MAAM,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;YACzC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;gBACnC,MAAM,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;aAC7C;YACD,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;YACnC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;SAC5D;QAAC,OAAO,CAAC,EAAE;YACR,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;SACxE;QACD,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;KACzB;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE;QACxB,IAAI,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YACvC,wDAAa,OAAO,CAAC,GAAG,CAAC,UAAU,GAAC,CAAC;SACxC;aAAM;YACH,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,aAAa,CAAC,CAAC;SAC3D;KACJ;IACD,OAAO;AACX,CAAC;AA9CD,8BA8CC"}
|
package/lib/globalTeardown.js
CHANGED
|
@@ -5,7 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const playwright_config_js_1 = __importDefault(require("../playwright.config.js"));
|
|
8
9
|
async function globalTeardown() {
|
|
10
|
+
const currentProjectNames = playwright_config_js_1.default.projects.map((project) => project.name);
|
|
9
11
|
const oldFolder = path_1.default.join(process.cwd(), 'results-e2e-raw/');
|
|
10
12
|
const newFolder = path_1.default.join(process.cwd(), 'results-e2e/screenshots/');
|
|
11
13
|
fs_1.default.mkdirSync(newFolder, { recursive: true });
|
|
@@ -16,11 +18,13 @@ async function globalTeardown() {
|
|
|
16
18
|
const newFile = "SPS_" + oldSubFolder
|
|
17
19
|
.substring(oldSubFolder.indexOf("SPS") + 4)
|
|
18
20
|
.split('-')
|
|
19
|
-
.filter(e => !
|
|
21
|
+
.filter(e => !currentProjectNames.includes(e) && !e.includes('retry'))
|
|
20
22
|
.join('_')
|
|
21
23
|
.replace('_', ' ');
|
|
22
24
|
const newFilePath = `${newFolder}/${newFile}.${oldFile.split('.').pop()}`;
|
|
23
|
-
fs_1.default.
|
|
25
|
+
if (!fs_1.default.existsSync(newFilePath)) {
|
|
26
|
+
fs_1.default.copyFileSync(oldFilePath, newFilePath);
|
|
27
|
+
}
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalTeardown.js","sourceRoot":"","sources":["../src/globalTeardown.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,gDAAwB;
|
|
1
|
+
{"version":3,"file":"globalTeardown.js","sourceRoot":"","sources":["../src/globalTeardown.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,mFAA6C;AAE9B,KAAK,UAAU,cAAc;IACxC,MAAM,mBAAmB,GAAG,8BAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAA0B,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9F,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;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13 +7,15 @@ if (process.env.CONFIG_PATH) {
|
|
|
7
7
|
|
|
8
8
|
const reportName = process.env.SUITE ? `${process.env.SUITE}.xml` : `TEST-result.xml`;
|
|
9
9
|
|
|
10
|
-
const customViewport = process.env.VIEWPORT ? JSON.parse(process.env.VIEWPORT) : { width: 1536, height:
|
|
10
|
+
const customViewport = process.env.VIEWPORT ? JSON.parse(process.env.VIEWPORT) : { width: 1536, height: 844 };
|
|
11
11
|
|
|
12
12
|
let browserProject = [];
|
|
13
13
|
switch (process.env.BROWSER) {
|
|
14
14
|
case 'firefox':
|
|
15
15
|
browserProject = [{
|
|
16
16
|
name: 'firefox',
|
|
17
|
+
testIgnore: /.*Inventory.*/,
|
|
18
|
+
testMatch: /.*(test|spec)\.(js|ts|mjs)/,
|
|
17
19
|
use: {
|
|
18
20
|
...devices['Desktop Firefox'],
|
|
19
21
|
userAgent: devices['Desktop Firefox'].userAgent + ' SPS auto test run',
|
|
@@ -24,6 +26,8 @@ switch (process.env.BROWSER) {
|
|
|
24
26
|
case 'webkit':
|
|
25
27
|
browserProject = [{
|
|
26
28
|
name: 'webkit',
|
|
29
|
+
testIgnore: /.*Inventory.*/,
|
|
30
|
+
testMatch: /.*(test|spec)\.(js|ts|mjs)/,
|
|
27
31
|
use: {
|
|
28
32
|
...devices['Desktop Safari'],
|
|
29
33
|
userAgent: devices['Desktop Safari'].userAgent + ' SPS auto test run',
|
|
@@ -34,6 +38,8 @@ switch (process.env.BROWSER) {
|
|
|
34
38
|
case 'edge':
|
|
35
39
|
browserProject = [{
|
|
36
40
|
name: 'msedge',
|
|
41
|
+
testIgnore: /.*Inventory.*/,
|
|
42
|
+
testMatch: /.*(test|spec)\.(js|ts|mjs)/,
|
|
37
43
|
use: {
|
|
38
44
|
channel: 'msedge',
|
|
39
45
|
...devices['Desktop Edge'],
|
|
@@ -45,6 +51,8 @@ switch (process.env.BROWSER) {
|
|
|
45
51
|
default:
|
|
46
52
|
browserProject = [{
|
|
47
53
|
name: 'chromium',
|
|
54
|
+
testIgnore: /.*Inventory.*/,
|
|
55
|
+
testMatch: /.*(test|spec)\.(js|ts|mjs)/,
|
|
48
56
|
use: {
|
|
49
57
|
channel: 'chrome',
|
|
50
58
|
...devices['Desktop Chrome'],
|
|
@@ -54,6 +62,18 @@ switch (process.env.BROWSER) {
|
|
|
54
62
|
}];
|
|
55
63
|
break;
|
|
56
64
|
}
|
|
65
|
+
// Added a specific no-retry suite workaround till the following request is done:
|
|
66
|
+
// https://github.com/microsoft/playwright/issues/10825
|
|
67
|
+
browserProject.push(
|
|
68
|
+
{
|
|
69
|
+
name: 'Inventory',
|
|
70
|
+
testMatch: /.*Inventory.*(test|spec)\.(js|ts|mjs)/,
|
|
71
|
+
retries: 0,
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const storageStatePath = process.env.ENV && process.env.ENV.includes('prod')
|
|
75
|
+
? path.join(process.cwd(), 'results-e2e/auth/storageStateProd.json')
|
|
76
|
+
: path.join(process.cwd(), 'results-e2e/auth/storageStateTest.json');
|
|
57
77
|
|
|
58
78
|
/**
|
|
59
79
|
* See https://playwright.dev/docs/test-configuration.
|
|
@@ -73,7 +93,7 @@ const config = {
|
|
|
73
93
|
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
74
94
|
forbidOnly: !!process.env.CI,
|
|
75
95
|
/* Retry on CI only */
|
|
76
|
-
retries:
|
|
96
|
+
retries: 1,//+process.env.RETRIES || 0,
|
|
77
97
|
/* Opt out of parallel tests on CI. */
|
|
78
98
|
workers: +process.env.WORKERS || 1,
|
|
79
99
|
/* Stop test suite execution after reaching this number of failed tests and skip any tests that were not executed yet. */
|
|
@@ -89,7 +109,7 @@ const config = {
|
|
|
89
109
|
globalTeardown: require.resolve('./lib/globalTeardown'),
|
|
90
110
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
91
111
|
use: {
|
|
92
|
-
storageState: path.join(process.cwd(), 'results-e2e/auth/storageState.json'),
|
|
112
|
+
storageState: storageStatePath,//path.join(process.cwd(), 'results-e2e/auth/storageState.json'),
|
|
93
113
|
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
|
|
94
114
|
actionTimeout: +process.env.ACTION_TIMEOUT || 30000,
|
|
95
115
|
/* Collect screenshot after each test failure. See https://playwright.dev/docs/test-configuration#automatic-screenshots */
|
package/src/globalSetup.ts
CHANGED
|
@@ -3,7 +3,15 @@ import path from 'path';
|
|
|
3
3
|
import { chromium } from '@playwright/test';
|
|
4
4
|
|
|
5
5
|
const domain = 'commerce.spscommerce.com';
|
|
6
|
-
|
|
6
|
+
let baseUrl = 'https://test.' + domain;
|
|
7
|
+
let storageFile = path.join(process.cwd(), `results-e2e/auth/storageStateTest.json`);
|
|
8
|
+
let traceFile = path.join(process.cwd(), 'results-e2e/auth/globalSetupTest.zip');
|
|
9
|
+
|
|
10
|
+
if (process.env.ENV && process.env.ENV.includes('prod')) {
|
|
11
|
+
baseUrl = 'https://' + domain;
|
|
12
|
+
storageFile = path.join(process.cwd(), `results-e2e/auth/storageStateProd.json`);
|
|
13
|
+
traceFile = path.join(process.cwd(), 'results-e2e/auth/globalSetupProd.zip');
|
|
14
|
+
}
|
|
7
15
|
|
|
8
16
|
export default async function globalSetup(): Promise<void> {
|
|
9
17
|
// Remove custom sub-folders for test artifacts
|
|
@@ -13,10 +21,12 @@ export default async function globalSetup(): Promise<void> {
|
|
|
13
21
|
if (!subFolder.includes('auth')) { fs.rmSync(resultsFolder + subFolder, { recursive: true, force: true }); }
|
|
14
22
|
}
|
|
15
23
|
}
|
|
16
|
-
// Launch browser and log in if storageState.json does not exist
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
// Launch browser and log in if storageState.json does not exist OR auth expires soon
|
|
25
|
+
const currentTS = new Date().getTime();
|
|
26
|
+
if (!fs.existsSync(storageFile) ||
|
|
27
|
+
(fs.existsSync(storageFile) &&
|
|
28
|
+
((JSON.parse(fs.readFileSync(storageFile, 'utf8')).origins[0].localStorage.find(o => o.name === 'expires_at').value - currentTS) / 60000) < 30)
|
|
29
|
+
) {
|
|
20
30
|
const browser = await chromium.launch({ headless: false }); // { headless: false }
|
|
21
31
|
const context = await browser.newContext();
|
|
22
32
|
await context.tracing.start({ screenshots: true, snapshots: true });
|
package/src/globalTeardown.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import config from '../playwright.config.js';
|
|
3
4
|
|
|
4
5
|
export default async function globalTeardown(): Promise<void> {
|
|
6
|
+
const currentProjectNames = config.projects.map((project: { name: string; }) => project.name);
|
|
5
7
|
const oldFolder = path.join(process.cwd(), 'results-e2e-raw/');
|
|
6
8
|
const newFolder = path.join(process.cwd(), 'results-e2e/screenshots/');
|
|
7
9
|
fs.mkdirSync(newFolder, { recursive: true });
|
|
@@ -12,11 +14,13 @@ export default async function globalTeardown(): Promise<void> {
|
|
|
12
14
|
const newFile = "SPS_" + oldSubFolder
|
|
13
15
|
.substring(oldSubFolder.indexOf("SPS") + 4)
|
|
14
16
|
.split('-')
|
|
15
|
-
.filter(e => !
|
|
17
|
+
.filter(e => !currentProjectNames.includes(e) && !e.includes('retry'))
|
|
16
18
|
.join('_')
|
|
17
19
|
.replace('_', ' ');
|
|
18
20
|
const newFilePath = `${newFolder}/${newFile}.${oldFile.split('.').pop()}`;
|
|
19
|
-
fs.
|
|
21
|
+
if (!fs.existsSync(newFilePath)) {
|
|
22
|
+
fs.copyFileSync(oldFilePath, newFilePath);
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
26
|
}
|