@spscommerce/e2e-core 2.5.0 → 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 CHANGED
@@ -3,6 +3,6 @@
3
3
  # White list the required files
4
4
  !.yarnrc.yml
5
5
  !package.json
6
- !playwright.config.js
6
+ !playwright.config.ts
7
7
  !tsconfig.json
8
8
  !yarn.lock
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 | 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] |
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.js",
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.js"
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
@@ -0,0 +1,36 @@
1
+ import globals from 'globals';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { defineConfig, globalIgnores } from 'eslint/config';
5
+
6
+ import tsParser from '@typescript-eslint/parser';
7
+ import typescriptEslint from '@typescript-eslint/eslint-plugin';
8
+ import js from '@eslint/js';
9
+ import { FlatCompat } from '@eslint/eslintrc';
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+ const compat = new FlatCompat({
14
+ baseDirectory: __dirname, recommendedConfig: js.configs.recommended, allConfig: js.configs.all
15
+ });
16
+
17
+ export default defineConfig([globalIgnores(["node_modules/*", "lib/*"]), {
18
+ languageOptions: {
19
+ globals: {
20
+ ...globals.browser,
21
+ ...globals.amd,
22
+ ...globals.node,
23
+ },
24
+ parser: tsParser,
25
+ ecmaVersion: 12,
26
+ sourceType: "module",
27
+ parserOptions: {},
28
+ },
29
+
30
+ extends: compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"),
31
+
32
+ plugins: {
33
+ "@typescript-eslint": typescriptEslint,
34
+ },
35
+ rules: {},
36
+ }]);
@@ -1,35 +1,13 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
6
  const test_1 = require("@playwright/test");
30
- const matchers = __importStar(require("jest-extended"));
31
7
  const withMessage_js_1 = __importDefault(require("jest-expect-message/dist/withMessage.js"));
32
8
  const expect = (0, withMessage_js_1.default)(test_1.test.expect);
9
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
10
+ const matchers = require('jest-extended');
33
11
  expect.extend(matchers);
34
12
  exports.default = expect;
35
13
  //# sourceMappingURL=matchersSetup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"matchersSetup.js","sourceRoot":"","sources":["../src/matchersSetup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,wDAA0C;AAC1C,6FAAkE;AAElE,MAAM,MAAM,GAAG,IAAA,wBAAW,EAAC,WAAI,CAAC,MAAM,CAAC,CAAC;AAExC,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.5.0",
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 npx playwright test"
10
+ "test": "CONFIG_PATH=$(pwd)/.env HEADLESS=false playwright test"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
@@ -32,7 +32,8 @@
32
32
  "dotenv": "16.6.1",
33
33
  "eslint": "9.39.1",
34
34
  "jest-expect-message": "1.1.3",
35
- "jest-extended": "6.0.0",
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
- const path = require('path');
2
- const { devices } = require('@playwright/test');
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
- require('dotenv').config({ path: process.env.CONFIG_PATH });
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
- module.exports = config;
161
+ export default config;
@@ -1,9 +1,10 @@
1
1
  import { test } from '@playwright/test';
2
- import * as matchers from 'jest-extended';
3
2
  import withMessage from 'jest-expect-message/dist/withMessage.js';
4
3
 
5
4
  const expect = withMessage(test.expect);
6
5
 
6
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
7
+ const matchers = require('jest-extended');
7
8
  expect.extend(matchers);
8
9
 
9
10
  export default expect;
package/eslint.config.js DELETED
@@ -1,53 +0,0 @@
1
- const {
2
- defineConfig, globalIgnores
3
- } = require("eslint/config");
4
-
5
- const globals = require("globals");
6
- const tsParser = require("@typescript-eslint/parser");
7
- const typescriptEslint = require("@typescript-eslint/eslint-plugin");
8
- const js = require("@eslint/js");
9
-
10
- const {
11
- FlatCompat,
12
- } = require("@eslint/eslintrc");
13
-
14
- const compat = new FlatCompat({
15
- baseDirectory: __dirname,
16
- recommendedConfig: js.configs.recommended,
17
- allConfig: js.configs.all
18
- });
19
-
20
- module.exports = defineConfig([
21
- globalIgnores([
22
- "node_modules/*",
23
- "lib/*",
24
- "eslint.config.js"
25
- ]),
26
- {
27
- languageOptions: {
28
- globals: {
29
- ...globals.browser,
30
- ...globals.amd,
31
- ...globals.node,
32
- },
33
-
34
- parser: tsParser,
35
- "ecmaVersion": 12,
36
- "sourceType": "module",
37
- parserOptions: {},
38
- },
39
-
40
- extends: compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"),
41
-
42
- plugins: {
43
- "@typescript-eslint": typescriptEslint,
44
- },
45
-
46
- "rules": {
47
- "@typescript-eslint/no-explicit-any": "off",
48
- "@typescript-eslint/no-var-requires": "off",
49
- "@typescript-eslint/no-require-imports": "off",
50
- "no-empty-pattern": "off"
51
- },
52
- }
53
- ]);