@spscommerce/e2e-core 2.2.6 → 2.2.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/.eslintrc.js +2 -0
- package/README.md +6 -2
- package/lib/globalSetup.js +5 -1
- package/lib/globalSetup.js.map +1 -1
- package/package.json +3 -3
- package/playwright.config.js +2 -2
- package/src/globalSetup.ts +6 -4
- package/src/globalTeardown.ts +1 -3
- package/src/loggerSetup.ts +3 -1
package/.eslintrc.js
CHANGED
package/README.md
CHANGED
|
@@ -19,8 +19,10 @@ export USER_PASSWORD="EXAMPLE_PASSWORD"
|
|
|
19
19
|
|
|
20
20
|
5. Create .env file in the tests-e2e/ directory with an appropriate process.env variables listed below in the table. E.g.:
|
|
21
21
|
```
|
|
22
|
-
|
|
22
|
+
TEST_TIMEOUT=75000
|
|
23
|
+
ACTION_TIMEOUT=45000
|
|
23
24
|
WORKERS=6
|
|
25
|
+
REPO_NAME=fulfillment-ui-v2
|
|
24
26
|
VIEWPORT={"width": 1920, "height": 1080}
|
|
25
27
|
```
|
|
26
28
|
| Variable | description | default | possible values |
|
|
@@ -28,7 +30,8 @@ VIEWPORT={"width": 1920, "height": 1080}
|
|
|
28
30
|
| HEADLESS | launch browser in headless/headful mode | true | true, false |
|
|
29
31
|
| BROWSER | use + as a separator, e.g edge+firefox | chromium | chromium, firefox, webkit, edge |
|
|
30
32
|
| ENV | auth state is invoked for the defined env | test | test, prod |
|
|
31
|
-
|
|
|
33
|
+
| TEST_TIMEOUT | global timeout for each test | 30000 | [number_in_ms] |
|
|
34
|
+
| ACTION_TIMEOUT | global timeout for each PW action, like click() | 30000 | [number_in_ms] |
|
|
32
35
|
| WORKERS | number of workers (test threads) | 1 | [number] |
|
|
33
36
|
| TRACER | create PW actions trace file per each failed test | false | true, false |
|
|
34
37
|
| VIEWPORT | emulates consistent viewport for each page | {"width": 1536, "height": 960} | [string] |
|
|
@@ -37,6 +40,7 @@ VIEWPORT={"width": 1920, "height": 1080}
|
|
|
37
40
|
| TEST_DIR | used in package.json: tests directory path | - | [string] |
|
|
38
41
|
| CONFIG_PATH | used in package.json: .env file path | - | [string] |
|
|
39
42
|
| SETUP_PATH | used in package.json: globalSetup.js file path | - | [string] |
|
|
43
|
+
| REPO_NAME | creates GH repo link on test in log files | - | [string] |
|
|
40
44
|
|
|
41
45
|
6. Setup the following "scripts" commands in the `package.json` according to your paths:
|
|
42
46
|
```
|
package/lib/globalSetup.js
CHANGED
|
@@ -30,7 +30,7 @@ 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
|
-
const baseUrl = process.env.ENV && process.env.ENV
|
|
33
|
+
const baseUrl = process.env.ENV && process.env.ENV.includes('prod') ? 'https://' + domain : 'https://test.' + domain;
|
|
34
34
|
async function globalSetup() {
|
|
35
35
|
// Remove custom sub-folders for test artifacts
|
|
36
36
|
const resultsFolder = path_1.default.join(process.cwd(), 'results-e2e/');
|
|
@@ -56,6 +56,10 @@ async function globalSetup() {
|
|
|
56
56
|
await page.click('button#btn-next');
|
|
57
57
|
await page.fill('input[type="password"]', process.env.USER_PASSWORD);
|
|
58
58
|
await page.click('button#btn-login');
|
|
59
|
+
await page.waitForURL(/^((?!login).)*$/);
|
|
60
|
+
if (page.url().includes('select-org')) {
|
|
61
|
+
await page.click('button[type="submit"]');
|
|
62
|
+
}
|
|
59
63
|
await page.waitForURL(/launchpad/);
|
|
60
64
|
await page.context().storageState({ path: storageFile });
|
|
61
65
|
}
|
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,GA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AO,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;AAED,kBAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spscommerce/e2e-core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.9",
|
|
4
4
|
"description": "An automation test framework which is based on Playwright.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@alex_neo/jest-expect-message": "^1.0.5",
|
|
28
28
|
"@playwright/test": "^1.21.1",
|
|
29
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
30
|
-
"@typescript-eslint/parser": "^
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^5.22.0",
|
|
30
|
+
"@typescript-eslint/parser": "^5.22.0",
|
|
31
31
|
"dotenv": "^16.0.0",
|
|
32
32
|
"eslint": "^7.32.0",
|
|
33
33
|
"jest-extended": "^1.2.0",
|
package/playwright.config.js
CHANGED
|
@@ -47,7 +47,7 @@ const config = {
|
|
|
47
47
|
/* Directory that will be recursively scanned for test files. */
|
|
48
48
|
testDir: process.env.TEST_DIR,
|
|
49
49
|
/* Maximum time one test can run for. */
|
|
50
|
-
timeout: +process.env.
|
|
50
|
+
timeout: +process.env.TEST_TIMEOUT || 30000,
|
|
51
51
|
/* Maximum time expect() should wait for the condition to be met. */
|
|
52
52
|
expect: {
|
|
53
53
|
timeout: 5000
|
|
@@ -73,7 +73,7 @@ const config = {
|
|
|
73
73
|
use: {
|
|
74
74
|
storageState: path.join(process.cwd(), 'results-e2e/auth/storageState.json'),
|
|
75
75
|
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
|
|
76
|
-
actionTimeout: 30000,
|
|
76
|
+
actionTimeout: +process.env.ACTION_TIMEOUT || 30000,
|
|
77
77
|
/* Collect screenshot after each test failure. See https://playwright.dev/docs/test-configuration#automatic-screenshots */
|
|
78
78
|
screenshot: 'only-on-failure',
|
|
79
79
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
package/src/globalSetup.ts
CHANGED
|
@@ -3,9 +3,9 @@ import path from 'path';
|
|
|
3
3
|
import { chromium } from '@playwright/test';
|
|
4
4
|
|
|
5
5
|
const domain = 'commerce.spscommerce.com';
|
|
6
|
-
const baseUrl = process.env.ENV && process.env.ENV
|
|
6
|
+
const baseUrl = process.env.ENV && process.env.ENV.includes('prod') ? 'https://' + domain : 'https://test.' + domain;
|
|
7
7
|
|
|
8
|
-
async function globalSetup() {
|
|
8
|
+
export default async function globalSetup(): Promise<void> {
|
|
9
9
|
// Remove custom sub-folders for test artifacts
|
|
10
10
|
const resultsFolder = path.join(process.cwd(), 'results-e2e/');
|
|
11
11
|
if (fs.existsSync(resultsFolder)) {
|
|
@@ -28,6 +28,10 @@ async function globalSetup() {
|
|
|
28
28
|
await page.click('button#btn-next');
|
|
29
29
|
await page.fill('input[type="password"]', process.env.USER_PASSWORD);
|
|
30
30
|
await page.click('button#btn-login');
|
|
31
|
+
await page.waitForURL(/^((?!login).)*$/);
|
|
32
|
+
if (page.url().includes('select-org')) {
|
|
33
|
+
await page.click('button[type="submit"]');
|
|
34
|
+
}
|
|
31
35
|
await page.waitForURL(/launchpad/);
|
|
32
36
|
await page.context().storageState({ path: storageFile });
|
|
33
37
|
} catch (e) {
|
|
@@ -46,5 +50,3 @@ async function globalSetup() {
|
|
|
46
50
|
}
|
|
47
51
|
return;
|
|
48
52
|
}
|
|
49
|
-
|
|
50
|
-
export default globalSetup;
|
package/src/globalTeardown.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
|
|
4
|
-
async function globalTeardown() {
|
|
4
|
+
export default async function globalTeardown(): Promise<void> {
|
|
5
5
|
const oldFolder = path.join(process.cwd(), 'results-e2e-raw/');
|
|
6
6
|
const newFolder = path.join(process.cwd(), 'results-e2e/screenshots/');
|
|
7
7
|
fs.mkdirSync(newFolder, { recursive: true });
|
|
@@ -17,5 +17,3 @@ async function globalTeardown() {
|
|
|
17
17
|
}
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
export default globalTeardown;
|
package/src/loggerSetup.ts
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { Page } from '@playwright/test';
|
|
4
4
|
|
|
5
|
-
let access:
|
|
5
|
+
let access: fs.WriteStream;
|
|
6
6
|
|
|
7
7
|
export async function enableLogger(file: string[], page: Page): Promise<void> {
|
|
8
8
|
// file:
|
|
@@ -57,3 +57,5 @@ export async function disableLogger(): Promise<void> {
|
|
|
57
57
|
access && access.end();
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
+
|
|
61
|
+
export const log = console.log.bind(console);
|