@spscommerce/e2e-core 2.5.1 → 2.6.0
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/.dockerignore +1 -1
- package/README.md +26 -21
- package/eslint.config.mjs +11 -13
- package/lib/matchersSetup.js +1 -0
- package/lib/matchersSetup.js.map +1 -1
- package/package.json +3 -2
- package/{playwright.config.js → playwright.config.ts} +7 -6
- package/src/matchersSetup.ts +1 -0
package/.dockerignore
CHANGED
package/README.md
CHANGED
|
@@ -27,25 +27,26 @@ REPO_NAME=fulfillment-ui-v2
|
|
|
27
27
|
BASEURL=https://test.commerce.spscommerce.com/fulfillment
|
|
28
28
|
VIEWPORT={"width": 1920, "height": 1080}
|
|
29
29
|
```
|
|
30
|
-
| Variable
|
|
31
|
-
|
|
32
|
-
| HEADLESS
|
|
33
|
-
| BROWSER
|
|
34
|
-
| TEST_TIMEOUT
|
|
35
|
-
| EXPECT_TIMEOUT
|
|
36
|
-
| ACTION_TIMEOUT
|
|
37
|
-
| SLOWMO
|
|
38
|
-
| WORKERS
|
|
39
|
-
| TRACER
|
|
40
|
-
| VIEWPORT
|
|
41
|
-
| CI
|
|
42
|
-
| SUITE
|
|
43
|
-
| ENV
|
|
44
|
-
| BASEURL
|
|
45
|
-
| TEST_DIR
|
|
46
|
-
| CONFIG_PATH
|
|
47
|
-
| SETUP_PATH
|
|
48
|
-
| REPO_NAME
|
|
30
|
+
| Variable | description | default | possible values |
|
|
31
|
+
|:----------------|----------------------------------------------------|--------------------------------|---------------------------------|
|
|
32
|
+
| HEADLESS | launch browser in headless/headful mode | true | true, false |
|
|
33
|
+
| BROWSER | use + as a separator, e.g edge+firefox | chromium | chromium, firefox, webkit, edge |
|
|
34
|
+
| TEST_TIMEOUT | global timeout for each test | 30000 | [number_in_ms] |
|
|
35
|
+
| EXPECT_TIMEOUT | global timeout for each expect | 5000 | [number_in_ms] |
|
|
36
|
+
| ACTION_TIMEOUT | global timeout for each PW action, like click() | 30000 | [number_in_ms] |
|
|
37
|
+
| SLOWMO | slows down the actions by the specified ms | 0 | [number_in_ms] |
|
|
38
|
+
| WORKERS | number of workers (test threads) | 1 | [number] |
|
|
39
|
+
| TRACER | create PW actions trace file per each failed test | false | true, false |
|
|
40
|
+
| VIEWPORT | emulates consistent viewport for each page | {"width": 1536, "height": 960} | [string] |
|
|
41
|
+
| CI | used in CI: forbidOnly and maxFailures are applied | false | true, false |
|
|
42
|
+
| SUITE | used in CI: report file name is created per suite | TEST-results.xml | [string] |
|
|
43
|
+
| ENV | invoked auth state environment flag* | test | test, prod |
|
|
44
|
+
| BASEURL | auth state is invoked for the provided url* | - (required) | [string] |
|
|
45
|
+
| TEST_DIR | used in package.json: tests directory path | - (required) | [string] |
|
|
46
|
+
| CONFIG_PATH | used in package.json: .env file path | - | [string] |
|
|
47
|
+
| SETUP_PATH | used in package.json: set sm-th before test start | - | [string] |
|
|
48
|
+
| REPO_NAME | creates GH repo link on test in log files | - | [string] |
|
|
49
|
+
| TESTRAIL_REPORT | enables custom TestRail reporter | - | true, false |
|
|
49
50
|
|
|
50
51
|
\* If you have several urls to run your tests for, consider the following possible set up in the SETUP_PATH file instead of providing BASEURL in the .env file:
|
|
51
52
|
```
|
|
@@ -77,8 +78,8 @@ It allows to set url for testing via CLI instead of setting it up in .env file.
|
|
|
77
78
|
|
|
78
79
|
6. Setup the following "scripts" commands in the `package.json` according to your paths:
|
|
79
80
|
```
|
|
80
|
-
"test": ". .credentials.sh && CONFIG_PATH=$(pwd)/.env SETUP_PATH=$(pwd)/src/helpers/urlSetup.js TEST_DIR=$(pwd) HEADLESS=false playwright test --config=node_modules/@spscommerce/e2e-core/playwright.config.
|
|
81
|
-
"test:ci": "CONFIG_PATH=$(pwd)/.env SETUP_PATH=$(pwd)/src/helpers/urlSetup.js TEST_DIR=$(pwd) CI=true playwright test --config=node_modules/@spscommerce/e2e-core/playwright.config.
|
|
81
|
+
"test": ". .credentials.sh && CONFIG_PATH=$(pwd)/.env SETUP_PATH=$(pwd)/src/helpers/urlSetup.js TEST_DIR=$(pwd) HEADLESS=false playwright test --config=node_modules/@spscommerce/e2e-core/playwright.config.ts",
|
|
82
|
+
"test:ci": "CONFIG_PATH=$(pwd)/.env SETUP_PATH=$(pwd)/src/helpers/urlSetup.js TEST_DIR=$(pwd) CI=true playwright test --config=node_modules/@spscommerce/e2e-core/playwright.config.ts"
|
|
82
83
|
```
|
|
83
84
|
7. Add your first test file (see Example.test.ts file).
|
|
84
85
|
|
|
@@ -203,6 +204,9 @@ jobs:
|
|
|
203
204
|
|
|
204
205
|
[TestingInspector@1](https://github.com/SPSCommerce/azure-pipelines-extensions/tree/main/extensions/workflow#testinginspector) - Azure DevOps extension used in CI pipeline to upload screenshot and log files into the test results report.
|
|
205
206
|
|
|
207
|
+
## Report to TestRail
|
|
208
|
+
We can use the custom [playwright-testrail-reporter](https://github.com/niche-tester/playwright-testrail-reporter) to publish tests result to the TestRail. It enables by the **TESTRAIL_REPORT** environment variable (you can check official docs for the usage capabilities and setup).
|
|
209
|
+
|
|
206
210
|
## Q&A
|
|
207
211
|
If you have any questions or difficulties with this package, reach out to us in [#ffqa](https://spscommerce.slack.com/archives/G01GH392AUX) on Slack.
|
|
208
212
|
Additional info over this framework could be found on [Confluence](https://atlassian.spscommerce.com/wiki/x/jQwlF).
|
|
@@ -217,3 +221,4 @@ Put in a PR against this repo if you fix a bug or come up with an improvement!
|
|
|
217
221
|
- [jest-expect-message](https://github.com/mattphillips/jest-expect-message) - gives ability to add a custom error message to the assertions
|
|
218
222
|
- [jest-extended](https://github.com/jest-community/jest-extended) - adds additional matchers to default ones making it easy to test everything 🙌
|
|
219
223
|
- [typescript](https://github.com/Microsoft/TypeScript) - language for application-scale JavaScript that adds optional types
|
|
224
|
+
- [playwright-testrail-reporter](https://github.com/niche-tester/playwright-testrail-reporter/tree/main) - custom reporter for Playwright Test to seamlessly integrate with TestRail
|
package/eslint.config.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import globals from 'globals';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {fileURLToPath} from 'node:url';
|
|
4
|
-
import {defineConfig, globalIgnores} from 'eslint/config';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
5
5
|
|
|
6
6
|
import tsParser from '@typescript-eslint/parser';
|
|
7
7
|
import typescriptEslint from '@typescript-eslint/eslint-plugin';
|
|
8
8
|
import js from '@eslint/js';
|
|
9
|
-
import {FlatCompat} from '@eslint/eslintrc';
|
|
9
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
|
10
10
|
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = path.dirname(__filename);
|
|
@@ -17,10 +17,14 @@ const compat = new FlatCompat({
|
|
|
17
17
|
export default defineConfig([globalIgnores(["node_modules/*", "lib/*"]), {
|
|
18
18
|
languageOptions: {
|
|
19
19
|
globals: {
|
|
20
|
-
...globals.browser,
|
|
20
|
+
...globals.browser,
|
|
21
|
+
...globals.amd,
|
|
22
|
+
...globals.node,
|
|
21
23
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
parser: tsParser,
|
|
25
|
+
ecmaVersion: 12,
|
|
26
|
+
sourceType: "module",
|
|
27
|
+
parserOptions: {},
|
|
24
28
|
},
|
|
25
29
|
|
|
26
30
|
extends: compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"),
|
|
@@ -28,11 +32,5 @@ export default defineConfig([globalIgnores(["node_modules/*", "lib/*"]), {
|
|
|
28
32
|
plugins: {
|
|
29
33
|
"@typescript-eslint": typescriptEslint,
|
|
30
34
|
},
|
|
31
|
-
|
|
32
|
-
"rules": {
|
|
33
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
34
|
-
"@typescript-eslint/no-var-requires": "off",
|
|
35
|
-
"@typescript-eslint/no-require-imports": "off",
|
|
36
|
-
"no-empty-pattern": "off"
|
|
37
|
-
},
|
|
35
|
+
rules: {},
|
|
38
36
|
}]);
|
package/lib/matchersSetup.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const test_1 = require("@playwright/test");
|
|
7
7
|
const withMessage_js_1 = __importDefault(require("jest-expect-message/dist/withMessage.js"));
|
|
8
8
|
const expect = (0, withMessage_js_1.default)(test_1.test.expect);
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
9
10
|
const matchers = require('jest-extended');
|
|
10
11
|
expect.extend(matchers);
|
|
11
12
|
exports.default = expect;
|
package/lib/matchersSetup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchersSetup.js","sourceRoot":"","sources":["../src/matchersSetup.ts"],"names":[],"mappings":";;;;;AAAA,2CAAwC;AACxC,6FAAkE;AAElE,MAAM,MAAM,GAAG,IAAA,wBAAW,EAAC,WAAI,CAAC,MAAM,CAAC,CAAC;AAExC,MAAM,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAExB,kBAAe,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"matchersSetup.js","sourceRoot":"","sources":["../src/matchersSetup.ts"],"names":[],"mappings":";;;;;AAAA,2CAAwC;AACxC,6FAAkE;AAElE,MAAM,MAAM,GAAG,IAAA,wBAAW,EAAC,WAAI,CAAC,MAAM,CAAC,CAAC;AAExC,iEAAiE;AACjE,MAAM,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAExB,kBAAe,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spscommerce/e2e-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
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",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"lint": "eslint .",
|
|
9
9
|
"build": "tsc --incremental -p tsconfig.json",
|
|
10
|
-
"test": "CONFIG_PATH=$(pwd)/.env HEADLESS=false
|
|
10
|
+
"test": "CONFIG_PATH=$(pwd)/.env HEADLESS=false playwright test"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"eslint": "9.39.1",
|
|
34
34
|
"jest-expect-message": "1.1.3",
|
|
35
35
|
"jest-extended": "1.2.1",
|
|
36
|
+
"playwright-testrail-reporter": "1.3.3",
|
|
36
37
|
"typescript": "4.9.5"
|
|
37
38
|
},
|
|
38
39
|
"packageManager": "yarn@4.4.0+sha512.91d93b445d9284e7ed52931369bc89a663414e5582d00eea45c67ddc459a2582919eece27c412d6ffd1bd0793ff35399381cb229326b961798ce4f4cc60ddfdb"
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { devices } from '@playwright/test';
|
|
3
|
+
import dotenv from 'dotenv';
|
|
3
4
|
|
|
4
5
|
if (process.env.CONFIG_PATH) {
|
|
5
|
-
|
|
6
|
+
dotenv.config({ path: process.env.CONFIG_PATH });
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
const reportName = process.env.SUITE ? `${process.env.SUITE}.xml` : `TEST-result.xml`;
|
|
@@ -100,8 +101,6 @@ const storageStatePath = process.env.ENV && process.env.ENV.includes('prod')
|
|
|
100
101
|
* See https://playwright.dev/docs/test-configuration
|
|
101
102
|
*/
|
|
102
103
|
|
|
103
|
-
// @ts-check
|
|
104
|
-
/** @type {import('@playwright/test').PlaywrightTestConfig} */
|
|
105
104
|
const config = {
|
|
106
105
|
/* Directory that will be recursively scanned for test files */
|
|
107
106
|
testDir: process.env.TEST_DIR,
|
|
@@ -123,6 +122,8 @@ const config = {
|
|
|
123
122
|
reporter: [
|
|
124
123
|
['junit', { outputFile: path.join(process.cwd(), `results-e2e/reports/${reportName}`) }],
|
|
125
124
|
['list'],
|
|
125
|
+
// Testrail custom reporter
|
|
126
|
+
...(process.env.TESTRAIL_REPORT && process.env.TESTRAIL_REPORT === 'true' ? [['playwright-testrail-reporter']] : []),
|
|
126
127
|
// Special reporters to transform video-s/screen-s to the form what can be displayed in the TestingInspector attachments
|
|
127
128
|
[path.resolve(__dirname, './lib/reporters/screenshots')],
|
|
128
129
|
[path.resolve(__dirname, './lib/reporters/junitFix'), { reportJunitFile: `results-e2e/reports/${reportName}` }],
|
|
@@ -157,4 +158,4 @@ const config = {
|
|
|
157
158
|
outputDir: path.join(process.cwd(), 'results-e2e-raw/')
|
|
158
159
|
};
|
|
159
160
|
|
|
160
|
-
|
|
161
|
+
export default config;
|
package/src/matchersSetup.ts
CHANGED