@spscommerce/e2e-core 2.10.0 → 2.10.1

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
@@ -1,10 +1,10 @@
1
1
  # Ignore all files by default
2
2
  *
3
3
  # White list the required files
4
+ !lib
4
5
  !package.json
5
6
  !pnpm-lock.yaml
6
7
  !pnpm-workspace.yaml
7
8
  !.npmrc
8
9
  !playwright.config.js
9
10
  !tsconfig.json
10
- !.env
package/.env.example ADDED
@@ -0,0 +1,4 @@
1
+ DOTENV_CONFIG_QUIET=true
2
+ BASEURL=https://test.commerce.spscommerce.com/fulfillment
3
+ USER_EMAIL=EXAMPLE_USER
4
+ USER_PASSWORD=EXAMPLE_PASSWORD
package/Dockerfile CHANGED
@@ -1,11 +1,9 @@
1
- FROM mcr.microsoft.com/playwright:v1.58.2-noble
1
+ FROM mcr.microsoft.com/playwright:v1.59.1-noble
2
2
 
3
- ARG BROWSER
3
+ ENV PNPM_HOME="/pnpm"
4
+ ENV PATH="$PNPM_HOME:$PATH"
5
+ RUN corepack enable
4
6
 
5
- RUN mkdir e2e
6
7
  WORKDIR /e2e
7
8
  COPY . .
8
- RUN corepack enable && corepack prepare pnpm@10.32.1 --activate
9
9
  RUN pnpm i
10
- RUN if [ "$BROWSER" = "edge" ]; then npx playwright install msedge --only-shell ; fi
11
- RUN if [ "$BROWSER" = "chrome" ]; then npx playwright install chrome --only-shell ; fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spscommerce/e2e-core",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
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",
@@ -12,7 +12,8 @@
12
12
  "reset": "pnpm clean && pnpm store prune",
13
13
  "lint": "eslint .",
14
14
  "build": "tsc --incremental -p tsconfig.json",
15
- "test": "CONFIG_PATH=$(pwd)/.env HEADLESS=false playwright test",
15
+ "test": "HEADLESS=false playwright test",
16
+ "test:ci": "CI=true HEADLESS=true xvfb-run playwright test",
16
17
  "prepare": "husky || true"
17
18
  },
18
19
  "repository": {
@@ -31,18 +32,18 @@
31
32
  "author": "SPS Commerce",
32
33
  "license": "UNLICENSED",
33
34
  "dependencies": {
34
- "@playwright/test": "1.58.2",
35
- "@types/node": "25.0.6",
36
- "@typescript-eslint/eslint-plugin": "8.49.0",
37
- "@typescript-eslint/parser": "8.49.0",
38
- "dotenv": "17.3.1",
35
+ "@playwright/test": "1.59.1",
36
+ "@types/node": "25.6.0",
37
+ "@typescript-eslint/eslint-plugin": "8.58.2",
38
+ "@typescript-eslint/parser": "8.58.2",
39
+ "dotenv": "17.4.2",
39
40
  "eslint": "9.39.4",
40
41
  "jest-expect-message": "1.1.3",
41
42
  "jest-extended": "1.2.1",
42
43
  "playwright-testrail-reporter": "1.3.3",
43
44
  "typescript": "5.9.3"
44
45
  },
45
- "packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be",
46
+ "packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319",
46
47
  "devDependencies": {
47
48
  "@commitlint/cli": "20.5.0",
48
49
  "@commitlint/config-conventional": "20.5.0",
@@ -1,8 +1,22 @@
1
+ const fs = require('fs');
1
2
  const path = require('path');
3
+ const dotenv = require('dotenv');
4
+
2
5
  const { devices } = require('@playwright/test');
3
6
 
7
+ // Set the current working directory to the root of the project to make sure all the paths are correct
8
+ const TEST_DIR = path.resolve(process.env.TEST_DIR || __dirname);
9
+ process.chdir(TEST_DIR);
10
+
11
+ // try to load environment variables from the specified path (path to the .env file)
4
12
  if (process.env.CONFIG_PATH) {
5
- require('dotenv').config({ path: process.env.CONFIG_PATH });
13
+ dotenv.config({path: process.env.CONFIG_PATH});
14
+ } else {
15
+ // if CONFIG_PATH is not specified, try to load .env file from the current working directory
16
+ const configPath = path.join(TEST_DIR, '.env');
17
+ if (fs.existsSync(configPath)) {
18
+ dotenv.config({path: configPath});
19
+ }
6
20
  }
7
21
 
8
22
  const reportName = process.env.SUITE ? `${process.env.SUITE}.xml` : `TEST-result.xml`;
@@ -11,89 +25,99 @@ const customViewport = process.env.VIEWPORT ? JSON.parse(process.env.VIEWPORT) :
11
25
  let browserProject = [];
12
26
  switch (process.env.BROWSER) {
13
27
  case 'firefox':
14
- browserProject = [{
15
- name: 'firefox',
16
- testMatch: /.*(test|spec)\.(js|ts|mjs)/,
17
- use: {
18
- ...devices['Desktop Firefox'],
19
- userAgent: devices['Desktop Firefox'].userAgent + ' SPS auto test run',
20
- viewport: customViewport,
21
- contextOptions: {
22
- // bypassCSP: true,
23
- setIgnoreHTTPSErrors: true
28
+ browserProject = [
29
+ {
30
+ name: 'firefox',
31
+ testMatch: /.*(test|spec)\.(js|ts|mjs)/,
32
+ use: {
33
+ ...devices['Desktop Firefox'],
34
+ userAgent:
35
+ devices['Desktop Firefox'].userAgent + ' SPS auto test run',
36
+ viewport: customViewport,
37
+ contextOptions: {
38
+ // bypassCSP: true,
39
+ setIgnoreHTTPSErrors: true,
40
+ },
24
41
  },
25
42
  },
26
- }];
43
+ ];
27
44
  break;
28
45
  case 'webkit':
29
- browserProject = [{
30
- name: 'webkit',
31
- testMatch: /.*(test|spec)\.(js|ts|mjs)/,
32
- use: {
33
- ...devices['Desktop Safari'],
34
- userAgent: devices['Desktop Safari'].userAgent + ' SPS auto test run',
35
- viewport: customViewport,
36
- contextOptions: {
37
- // bypassCSP: true,
38
- setIgnoreHTTPSErrors: true
46
+ browserProject = [
47
+ {
48
+ name: 'webkit',
49
+ testMatch: /.*(test|spec)\.(js|ts|mjs)/,
50
+ use: {
51
+ ...devices['Desktop Safari'],
52
+ userAgent: devices['Desktop Safari'].userAgent + ' SPS auto test run',
53
+ viewport: customViewport,
54
+ contextOptions: {
55
+ // bypassCSP: true,
56
+ setIgnoreHTTPSErrors: true,
57
+ },
39
58
  },
40
59
  },
41
- }];
60
+ ];
42
61
  break;
43
62
  case 'edge':
44
- browserProject = [{
45
- name: 'msedge',
46
- testMatch: /.*(test|spec)\.(js|ts|mjs)/,
47
- use: {
48
- channel: 'msedge',
49
- ...devices['Desktop Edge'],
50
- userAgent: devices['Desktop Edge'].userAgent + ' SPS auto test run',
51
- viewport: customViewport,
52
- permissions: ['local-network-access'],
53
- contextOptions: {
54
- // bypassCSP: true,
55
- setIgnoreHTTPSErrors: true
63
+ browserProject = [
64
+ {
65
+ name: 'msedge',
66
+ testMatch: /.*(test|spec)\.(js|ts|mjs)/,
67
+ use: {
68
+ channel: 'msedge',
69
+ ...devices['Desktop Edge'],
70
+ userAgent: devices['Desktop Edge'].userAgent + ' SPS auto test run',
71
+ viewport: customViewport,
72
+ permissions: ['local-network-access'],
73
+ contextOptions: {
74
+ // bypassCSP: true,
75
+ setIgnoreHTTPSErrors: true,
76
+ },
77
+ // launchOptions: {
78
+ // args: [
79
+ // "--disable-web-security",
80
+ // "--allow-insecure-localhost",
81
+ // "--ignore-certificate-errors",
82
+ // "--allow-running-insecure-content"
83
+ // ]
84
+ // }
56
85
  },
57
- // launchOptions: {
58
- // args: [
59
- // "--disable-web-security",
60
- // "--allow-insecure-localhost",
61
- // "--ignore-certificate-errors",
62
- // "--allow-running-insecure-content"
63
- // ]
64
- // }
65
86
  },
66
- }];
87
+ ];
67
88
  break;
68
89
  default:
69
- browserProject = [{
70
- name: 'chromium',
71
- testMatch: /.*(test|spec)\.(js|ts|mjs)/,
72
- use: {
73
- ...devices['Desktop Chrome'],
74
- userAgent: devices['Desktop Chrome'].userAgent + ' SPS auto test run',
75
- viewport: customViewport,
76
- contextOptions: {
77
- // bypassCSP: true,
78
- setIgnoreHTTPSErrors: true
90
+ browserProject = [
91
+ {
92
+ name: 'chromium',
93
+ testMatch: /.*(test|spec)\.(js|ts|mjs)/,
94
+ use: {
95
+ ...devices['Desktop Chrome'],
96
+ userAgent: devices['Desktop Chrome'].userAgent + ' SPS auto test run',
97
+ viewport: customViewport,
98
+ contextOptions: {
99
+ // bypassCSP: true,
100
+ setIgnoreHTTPSErrors: true,
101
+ },
102
+ permissions: ['local-network-access'],
103
+ // launchOptions: {
104
+ // args: [
105
+ // "--disable-web-security",
106
+ // "--allow-insecure-localhost",
107
+ // "--ignore-certificate-errors",
108
+ // "--allow-running-insecure-content"
109
+ // ]
110
+ // }
79
111
  },
80
- permissions: ['local-network-access']
81
- // launchOptions: {
82
- // args: [
83
- // "--disable-web-security",
84
- // "--allow-insecure-localhost",
85
- // "--ignore-certificate-errors",
86
- // "--allow-running-insecure-content"
87
- // ]
88
- // }
89
112
  },
90
- }];
113
+ ];
91
114
  break;
92
115
  }
93
116
 
94
- const storageStatePath = process.env.ENV && process.env.ENV.includes('prod')
95
- ? path.join(process.cwd(), 'results-e2e/auth/storageStateProd.json')
96
- : path.join(process.cwd(), 'results-e2e/auth/storageStateTest.json');
117
+ const storageStatePath =
118
+ process.env.ENV && process.env.ENV.includes('prod')
119
+ ? path.join(TEST_DIR, 'results-e2e/auth/storageStateProd.json')
120
+ : path.join(TEST_DIR, 'results-e2e/auth/storageStateTest.json');
97
121
 
98
122
  /**
99
123
  * See https://playwright.dev/docs/test-configuration
@@ -103,7 +127,7 @@ const storageStatePath = process.env.ENV && process.env.ENV.includes('prod')
103
127
  /** @type {import('@playwright/test').PlaywrightTestConfig} */
104
128
  const config = {
105
129
  /* Directory that will be recursively scanned for test files */
106
- testDir: process.env.TEST_DIR,
130
+ testDir: TEST_DIR,
107
131
  /* Maximum time one test can run for. */
108
132
  timeout: +process.env.TEST_TIMEOUT || 30000,
109
133
  /* Maximum time expect() should wait for the condition to be met */
@@ -120,16 +144,21 @@ const config = {
120
144
  maxFailures: process.env.CI ? 8 : 0,
121
145
  /* Reporter to use. See https://playwright.dev/docs/test-reporters */
122
146
  reporter: [
123
- ['junit', { outputFile: path.join(process.cwd(), `results-e2e/reports/${reportName}`) }],
147
+ [
148
+ 'junit',
149
+ {outputFile: path.join(TEST_DIR, `results-e2e/reports/${reportName}`)},
150
+ ],
124
151
  ['list'],
125
152
  // Special reporters to transform video-s/screen-s to the form what can be displayed in the TestingInspector attachments
126
153
  [path.resolve(__dirname, './lib/reporters/screenshots')],
127
- [path.resolve(__dirname, './lib/reporters/junitFix'), { reportJunitFile: `results-e2e/reports/${reportName}` }],
154
+ [
155
+ path.resolve(__dirname, './lib/reporters/junitFix'),
156
+ {reportJunitFile: path.join(TEST_DIR, `results-e2e/reports/${reportName}`)},
157
+ ],
128
158
  // Testrail custom reporter
129
159
  ...(process.env.TESTRAIL_REPORT && process.env.TESTRAIL_REPORT === 'true'
130
160
  ? [['playwright-testrail-reporter']]
131
- : []
132
- ),
161
+ : []),
133
162
  ],
134
163
  /* Global setup file must export a single function. This function will be run once before all the tests */
135
164
  globalSetup: require.resolve('./lib/globalSetup'),
@@ -143,22 +172,27 @@ const config = {
143
172
  /* Record video only when retrying a test for the first time. See https://playwright.dev/docs/test-configuration#automatic-screenshots */
144
173
  video: 'on-first-retry',
145
174
  /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
146
- trace: process.env.TRACER && (process.env.TRACER.toString().toLowerCase() === 'true') ? 'retain-on-failure' : 'off',
175
+ trace:
176
+ process.env.TRACER &&
177
+ process.env.TRACER.toString().toLowerCase() === 'true'
178
+ ? 'retain-on-failure'
179
+ : 'off',
147
180
  /* Run in headless mode by default (if process.env.HEADLESS is not specified) */
148
- headless: !process.env.HEADLESS || process.env.HEADLESS === 'true' ? true : false,
181
+ headless:
182
+ !process.env.HEADLESS || process.env.HEADLESS === 'true' ? true : false,
149
183
  /* Whether to ignore HTTPS errors when sending network requests */
150
184
  ignoreHTTPSErrors: true,
151
185
  /* Slow down Playwright operations by the specified amount of milliseconds */
152
186
  launchOptions: {
153
187
  slowMo: +process.env.SLOWMO || 0,
154
- }
188
+ },
155
189
  /* Base URL to use in actions like `await page.goto('/')` */
156
190
  // baseURL: 'http://localhost:3000',
157
191
  },
158
192
  /* Configure projects for major browsers */
159
193
  projects: browserProject,
160
194
  /* Folder for test artifacts such as screenshots, videos, traces, etc. (cleaned at the start) */
161
- outputDir: path.join(process.cwd(), 'results-e2e-raw/')
195
+ outputDir: path.join(TEST_DIR, 'results-e2e-raw/'),
162
196
  };
163
197
 
164
198
  module.exports = config;
package/.env DELETED
@@ -1,2 +0,0 @@
1
- BASEURL=https://test.commerce.spscommerce.com/fulfillment/
2
- DOTENV_CONFIG_QUIET=true