@spscommerce/e2e-core 2.4.11 → 2.4.12

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/Example.test.ts CHANGED
@@ -4,7 +4,7 @@ import { enableLogger, disableLogger } from './src/loggerSetup';
4
4
 
5
5
  test.describe('SPS_Example', () => {
6
6
 
7
- // test.describe.configure({ retries: 1 });
7
+ test.describe.configure({ retries: 1 });
8
8
 
9
9
  test.beforeEach(async ({ page }, testInfo) => {
10
10
  process.env.CI && await enableLogger(testInfo.titlePath, page);
package/lib/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './globalSetup';
2
- export * from './globalTeardown';
3
2
  export * from './loggerSetup';
4
3
  export { default as expect } from './matchersSetup';
package/lib/index.js CHANGED
@@ -19,7 +19,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.expect = void 0;
21
21
  __exportStar(require("./globalSetup"), exports);
22
- __exportStar(require("./globalTeardown"), exports);
23
22
  __exportStar(require("./loggerSetup"), exports);
24
23
  var matchersSetup_1 = require("./matchersSetup");
25
24
  Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return __importDefault(matchersSetup_1).default; } });
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,mDAAiC;AACjC,gDAA8B;AAC9B,iDAAoD;AAA3C,wHAAA,OAAO,OAAU"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,gDAA8B;AAC9B,iDAAoD;AAA3C,wHAAA,OAAO,OAAU"}
@@ -0,0 +1,10 @@
1
+ import type { Reporter } from '@playwright/test/reporter';
2
+ interface JUnitFixOptions {
3
+ reportJunitFile?: string;
4
+ }
5
+ declare class JunitFixReporter implements Reporter {
6
+ private readonly reportJunitFile;
7
+ constructor(options: JUnitFixOptions);
8
+ onEnd(): void;
9
+ }
10
+ export default JunitFixReporter;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
7
+ class JunitFixReporter {
8
+ reportJunitFile;
9
+ constructor(options) {
10
+ this.reportJunitFile = options.reportJunitFile;
11
+ }
12
+ onEnd() {
13
+ const report = fs_1.default.readFileSync(this.reportJunitFile);
14
+ const reportFixed = String(report).replaceAll(/<testcase(\s+)name="([^"]+?)"/gi, (_all, spaces, name) => {
15
+ // Replace 'test case > test name' to the 'test name test case'
16
+ if (name)
17
+ name = name.replaceAll(/ › /g, ' ');
18
+ return `<testcase${spaces}name="${name}"`;
19
+ });
20
+ fs_1.default.writeFileSync(this.reportJunitFile, reportFixed);
21
+ }
22
+ }
23
+ exports.default = JunitFixReporter;
24
+ //# sourceMappingURL=junitFix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"junitFix.js","sourceRoot":"","sources":["../../src/reporters/junitFix.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AAOpB,MAAM,gBAAgB;IACH,eAAe,CAAU;IAE1C,YAAY,OAAwB;QAClC,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IACjD,CAAC;IAED,KAAK;QACH,MAAM,MAAM,GAAG,YAAE,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACrD,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,CAC3C,iCAAiC,EACjC,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;YACrB,+DAA+D;YAC/D,IAAI,IAAI;gBAAE,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAC9C,OAAO,YAAY,MAAM,SAAS,IAAI,GAAG,CAAC;QAC5C,CAAC,CACF,CAAC;QACF,YAAE,CAAC,aAAa,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;CACF;AAED,kBAAe,gBAAgB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Reporter, TestCase, TestResult } from '@playwright/test/reporter';
2
+ declare class ScreenshotsReporter implements Reporter {
3
+ onTestEnd(test: TestCase, result: TestResult): void;
4
+ }
5
+ export default ScreenshotsReporter;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const path_1 = __importDefault(require("path"));
8
+ // Simple reporter for copy attachments to the screenshots folder
9
+ class ScreenshotsReporter {
10
+ onTestEnd(test, result) {
11
+ const screenshotsDirName = path_1.default.join(process.cwd(), 'results-e2e/screenshots/');
12
+ result.attachments.forEach(attachment => {
13
+ // Create folder if un-exists
14
+ if (!fs_1.default.existsSync(screenshotsDirName))
15
+ fs_1.default.mkdirSync(screenshotsDirName, { recursive: true });
16
+ // Copy file as '<description> <test name>.<file ext>'
17
+ fs_1.default.copyFileSync(attachment.path, path_1.default.join(screenshotsDirName, `${test.titlePath().at(-2)} ${test.title}${path_1.default.extname(attachment.path)}`));
18
+ });
19
+ }
20
+ }
21
+ exports.default = ScreenshotsReporter;
22
+ //# sourceMappingURL=screenshots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screenshots.js","sourceRoot":"","sources":["../../src/reporters/screenshots.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAGxB,iEAAiE;AACjE,MAAM,mBAAmB;IACvB,SAAS,CAAC,IAAc,EAAE,MAAkB;QAC1C,MAAM,kBAAkB,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,0BAA0B,CAAC,CAAC;QAChF,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YACtC,6BAA6B;YAC7B,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC;gBAAE,YAAE,CAAC,SAAS,CAAC,kBAAkB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9F,sDAAsD;YACtD,YAAE,CAAC,YAAY,CACb,UAAU,CAAC,IAAI,EACf,cAAI,CAAC,IAAI,CACP,kBAAkB,EAClB,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAC3E,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,kBAAe,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spscommerce/e2e-core",
3
- "version": "2.4.11",
3
+ "version": "2.4.12",
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",
@@ -121,12 +121,13 @@ const config = {
121
121
  /* Reporter to use. See https://playwright.dev/docs/test-reporters */
122
122
  reporter: [
123
123
  ['junit', { outputFile: path.join(process.cwd(), `results-e2e/reports/${reportName}`) }],
124
- ['list']
124
+ ['list'],
125
+ // Special reporters to transform video-s/screen-s to the form what can be displayed in the TestingInspector attachments
126
+ [path.resolve(__dirname, './src/reporters/screenshots.ts')],
127
+ [path.resolve(__dirname, './src/reporters/junitFix.ts'), { reportJunitFile: `results-e2e/reports/${reportName}` }],
125
128
  ],
126
129
  /* Global setup file must export a single function. This function will be run once before all the tests */
127
130
  globalSetup: require.resolve('./lib/globalSetup'),
128
- /* Similarly, run something once after all the tests. */
129
- globalTeardown: require.resolve('./lib/globalTeardown'),
130
131
  /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions */
131
132
  use: {
132
133
  storageState: !process.env.SKIP_AUTH ? storageStatePath : undefined,
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './globalSetup';
2
- export * from './globalTeardown';
3
2
  export * from './loggerSetup';
4
3
  export { default as expect } from './matchersSetup';
@@ -0,0 +1,29 @@
1
+ import fs from 'fs';
2
+ import type { Reporter } from '@playwright/test/reporter';
3
+
4
+ interface JUnitFixOptions {
5
+ reportJunitFile?: string;
6
+ }
7
+
8
+ class JunitFixReporter implements Reporter {
9
+ private readonly reportJunitFile!: string;
10
+
11
+ constructor(options: JUnitFixOptions) {
12
+ this.reportJunitFile = options.reportJunitFile;
13
+ }
14
+
15
+ onEnd() {
16
+ const report = fs.readFileSync(this.reportJunitFile);
17
+ const reportFixed = String(report).replaceAll(
18
+ /<testcase(\s+)name="([^"]+?)"/gi,
19
+ (_all, spaces, name) => {
20
+ // Replace 'test case > test name' to the 'test name test case'
21
+ if (name) name = name.replaceAll(/ › /g, ' ');
22
+ return `<testcase${spaces}name="${name}"`;
23
+ }
24
+ );
25
+ fs.writeFileSync(this.reportJunitFile, reportFixed);
26
+ }
27
+ }
28
+
29
+ export default JunitFixReporter;
@@ -0,0 +1,24 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import type { Reporter, TestCase, TestResult } from '@playwright/test/reporter';
4
+
5
+ // Simple reporter for copy attachments to the screenshots folder
6
+ class ScreenshotsReporter implements Reporter {
7
+ onTestEnd(test: TestCase, result: TestResult) {
8
+ const screenshotsDirName = path.join(process.cwd(), 'results-e2e/screenshots/');
9
+ result.attachments.forEach(attachment => {
10
+ // Create folder if un-exists
11
+ if (!fs.existsSync(screenshotsDirName)) fs.mkdirSync(screenshotsDirName, { recursive: true });
12
+ // Copy file as '<description> <test name>.<file ext>'
13
+ fs.copyFileSync(
14
+ attachment.path,
15
+ path.join(
16
+ screenshotsDirName,
17
+ `${test.titlePath().at(-2)} ${test.title}${path.extname(attachment.path)}`
18
+ )
19
+ );
20
+ });
21
+ }
22
+ }
23
+
24
+ export default ScreenshotsReporter;
@@ -1 +0,0 @@
1
- export default function globalTeardown(): Promise<void>;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const path_1 = __importDefault(require("path"));
8
- const playwright_config_js_1 = __importDefault(require("../playwright.config.js"));
9
- async function globalTeardown() {
10
- const currentProjectNames = playwright_config_js_1.default.projects.map((project) => project.name);
11
- const oldFolder = path_1.default.join(process.cwd(), 'results-e2e-raw/');
12
- const newFolder = path_1.default.join(process.cwd(), 'results-e2e/screenshots/');
13
- fs_1.default.mkdirSync(newFolder, { recursive: true });
14
- if (fs_1.default.existsSync(oldFolder)) {
15
- for (const oldSubFolder of fs_1.default.readdirSync(oldFolder)) {
16
- for (const oldFile of fs_1.default.readdirSync(path_1.default.join(oldFolder, oldSubFolder))) {
17
- const oldFilePath = `${oldFolder}/${oldSubFolder}/${oldFile}`;
18
- const newFile = "SPS_" + oldSubFolder
19
- .substring(oldSubFolder.indexOf("SPS") + 4)
20
- .split('-')
21
- .filter(e => !currentProjectNames.includes(e) && !e.includes('retry'))
22
- .join('_')
23
- .replace('_', ' ');
24
- const newFilePath = `${newFolder}/${newFile}.${oldFile.split('.').pop()}`;
25
- fs_1.default.copyFileSync(oldFilePath, newFilePath);
26
- }
27
- }
28
- }
29
- return;
30
- }
31
- exports.default = globalTeardown;
32
- //# sourceMappingURL=globalTeardown.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"globalTeardown.js","sourceRoot":"","sources":["../src/globalTeardown.ts"],"names":[],"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I,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;gBAC1E,YAAE,CAAC,YAAY,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;aAC7C;SACJ;KACJ;IACD,OAAO;AACX,CAAC;AArBD,iCAqBC"}
@@ -1,26 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import config from '../playwright.config.js';
4
-
5
- export default async function globalTeardown(): Promise<void> {
6
- const currentProjectNames = config.projects.map((project: { name: string; }) => project.name);
7
- const oldFolder = path.join(process.cwd(), 'results-e2e-raw/');
8
- const newFolder = path.join(process.cwd(), 'results-e2e/screenshots/');
9
- fs.mkdirSync(newFolder, { recursive: true });
10
- if (fs.existsSync(oldFolder)) {
11
- for (const oldSubFolder of fs.readdirSync(oldFolder)) {
12
- for (const oldFile of fs.readdirSync(path.join(oldFolder, oldSubFolder))) {
13
- const oldFilePath = `${oldFolder}/${oldSubFolder}/${oldFile}`;
14
- const newFile = "SPS_" + oldSubFolder
15
- .substring(oldSubFolder.indexOf("SPS") + 4)
16
- .split('-')
17
- .filter(e => !currentProjectNames.includes(e) && !e.includes('retry'))
18
- .join('_')
19
- .replace('_', ' ');
20
- const newFilePath = `${newFolder}/${newFile}.${oldFile.split('.').pop()}`;
21
- fs.copyFileSync(oldFilePath, newFilePath);
22
- }
23
- }
24
- }
25
- return;
26
- }