@spscommerce/e2e-core 2.0.2 → 2.1.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/helpers/index.ts +4 -0
- package/lib/globalSetup.d.ts +2 -0
- package/lib/globalSetup.js +119 -0
- package/lib/globalSetup.js.map +1 -0
- package/lib/globalTeardown.d.ts +2 -0
- package/lib/globalTeardown.js +63 -0
- package/lib/globalTeardown.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -0
- package/lib/loggerSetup.d.ts +3 -0
- package/lib/loggerSetup.js +109 -0
- package/lib/loggerSetup.js.map +1 -0
- package/lib/matchersSetup.d.ts +2 -0
- package/lib/matchersSetup.js +7 -0
- package/lib/matchersSetup.js.map +1 -0
- package/package.json +6 -3
- package/tsconfig.json +7 -5
package/helpers/index.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import fs from 'fs';
|
|
38
|
+
import path from 'path';
|
|
39
|
+
import { chromium } from '@playwright/test';
|
|
40
|
+
function globalSetup() {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
+
var resultsFolder, _i, _a, subFolder, storageFile, traceFile, browser, context, page, e_1, stat;
|
|
43
|
+
return __generator(this, function (_b) {
|
|
44
|
+
switch (_b.label) {
|
|
45
|
+
case 0:
|
|
46
|
+
resultsFolder = path.join(process.cwd(), 'results-e2e/');
|
|
47
|
+
if (fs.existsSync(resultsFolder)) {
|
|
48
|
+
for (_i = 0, _a = fs.readdirSync(resultsFolder); _i < _a.length; _i++) {
|
|
49
|
+
subFolder = _a[_i];
|
|
50
|
+
if (!subFolder.includes('auth')) {
|
|
51
|
+
fs.rmSync(resultsFolder + subFolder, { recursive: true, force: true });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
storageFile = path.join(process.cwd(), 'results-e2e/auth/storageState.json');
|
|
56
|
+
traceFile = path.join(process.cwd(), 'results-e2e/auth/globalSetup.zip');
|
|
57
|
+
if (!!fs.existsSync(storageFile)) return [3 /*break*/, 18];
|
|
58
|
+
return [4 /*yield*/, chromium.launch({ headless: false })];
|
|
59
|
+
case 1:
|
|
60
|
+
browser = _b.sent();
|
|
61
|
+
return [4 /*yield*/, browser.newContext()];
|
|
62
|
+
case 2:
|
|
63
|
+
context = _b.sent();
|
|
64
|
+
return [4 /*yield*/, context.tracing.start({ screenshots: true, snapshots: true })];
|
|
65
|
+
case 3:
|
|
66
|
+
_b.sent();
|
|
67
|
+
return [4 /*yield*/, context.newPage()];
|
|
68
|
+
case 4:
|
|
69
|
+
page = _b.sent();
|
|
70
|
+
_b.label = 5;
|
|
71
|
+
case 5:
|
|
72
|
+
_b.trys.push([5, 14, , 16]);
|
|
73
|
+
return [4 /*yield*/, page.goto(process.env.BASEURL)];
|
|
74
|
+
case 6:
|
|
75
|
+
_b.sent();
|
|
76
|
+
return [4 /*yield*/, page.waitForURL(/https:\/\/auth.*/)];
|
|
77
|
+
case 7:
|
|
78
|
+
_b.sent();
|
|
79
|
+
return [4 /*yield*/, page.fill('input[type="email"]', process.env.USER_EMAIL)];
|
|
80
|
+
case 8:
|
|
81
|
+
_b.sent();
|
|
82
|
+
return [4 /*yield*/, page.click('button#btn-next')];
|
|
83
|
+
case 9:
|
|
84
|
+
_b.sent();
|
|
85
|
+
return [4 /*yield*/, page.fill('input[type="password"]', process.env.USER_PASSWORD)];
|
|
86
|
+
case 10:
|
|
87
|
+
_b.sent();
|
|
88
|
+
return [4 /*yield*/, page.click('button#btn-login')];
|
|
89
|
+
case 11:
|
|
90
|
+
_b.sent();
|
|
91
|
+
return [4 /*yield*/, page.waitForURL(/launchpad/)];
|
|
92
|
+
case 12:
|
|
93
|
+
_b.sent();
|
|
94
|
+
return [4 /*yield*/, page.context().storageState({ path: storageFile })];
|
|
95
|
+
case 13:
|
|
96
|
+
_b.sent();
|
|
97
|
+
return [3 /*break*/, 16];
|
|
98
|
+
case 14:
|
|
99
|
+
e_1 = _b.sent();
|
|
100
|
+
console.log(e_1);
|
|
101
|
+
return [4 /*yield*/, context.tracing.stop({ path: traceFile })];
|
|
102
|
+
case 15:
|
|
103
|
+
_b.sent();
|
|
104
|
+
throw new Error('Error occurred while running globalSetup.ts file.');
|
|
105
|
+
case 16: return [4 /*yield*/, browser.close()];
|
|
106
|
+
case 17:
|
|
107
|
+
_b.sent();
|
|
108
|
+
return [3 /*break*/, 19];
|
|
109
|
+
case 18:
|
|
110
|
+
stat = fs.statSync(storageFile);
|
|
111
|
+
console.log(stat);
|
|
112
|
+
_b.label = 19;
|
|
113
|
+
case 19: return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
export default globalSetup;
|
|
119
|
+
//# sourceMappingURL=globalSetup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalSetup.js","sourceRoot":"","sources":["../helpers/globalSetup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,SAAe,WAAW;;;;;;oBAEhB,aAAa,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AI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAA;;oBAAzC,SAAyC,CAAC;oBAC1C,qBAAM,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAA;;oBAA9D,SAA8D,CAAC;oBAC/D,qBAAM,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAA;;oBAAnC,SAAmC,CAAC;oBACpC,qBAAM,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAA;;oBAApE,SAAoE,CAAC;oBACrE,qBAAM,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAA;;oBAApC,SAAoC,CAAC;oBACrC,qBAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAA;;oBAAlC,SAAkC,CAAC;oBACnC,qBAAM,IAAI,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAAA;;oBAAxD,SAAwD,CAAC;;;;oBAEzD,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAC;oBACf,qBAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAA;;oBAA/C,SAA+C,CAAC;oBAChD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;yBAEzE,qBAAM,OAAO,CAAC,KAAK,EAAE,EAAA;;oBAArB,SAAqB,CAAC;;;oBAEhB,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;oBACtC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;;;;;;CAEzB;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import fs from 'fs';
|
|
38
|
+
import path from 'path';
|
|
39
|
+
function globalTeardown() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
41
|
+
var oldFolder, newFolder, _i, _a, oldSubFolder, _b, _c, oldFile, oldFilePath, newFile, newFilePath;
|
|
42
|
+
return __generator(this, function (_d) {
|
|
43
|
+
oldFolder = path.join(process.cwd(), 'results-e2e-raw/');
|
|
44
|
+
newFolder = path.join(process.cwd(), 'results-e2e/screenshots/');
|
|
45
|
+
fs.mkdirSync(newFolder, { recursive: true });
|
|
46
|
+
if (fs.existsSync(oldFolder)) {
|
|
47
|
+
for (_i = 0, _a = fs.readdirSync(oldFolder); _i < _a.length; _i++) {
|
|
48
|
+
oldSubFolder = _a[_i];
|
|
49
|
+
for (_b = 0, _c = fs.readdirSync(path.join(oldFolder, oldSubFolder)); _b < _c.length; _b++) {
|
|
50
|
+
oldFile = _c[_b];
|
|
51
|
+
oldFilePath = "".concat(oldFolder, "/").concat(oldSubFolder, "/").concat(oldFile);
|
|
52
|
+
newFile = "FFUI_" + oldSubFolder.substring(oldSubFolder.indexOf("FFUI-")).split('-').slice(1, -1).join('_').replace('_', ' ');
|
|
53
|
+
newFilePath = "".concat(newFolder, "/").concat(newFile, ".").concat(oldFile.split('.').pop());
|
|
54
|
+
fs.copyFileSync(oldFilePath, newFilePath);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return [2 /*return*/];
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
export default globalTeardown;
|
|
63
|
+
//# sourceMappingURL=globalTeardown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalTeardown.js","sourceRoot":"","sources":["../helpers/globalTeardown.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,SAAe,cAAc;;;;YACnB,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;YACzD,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,0BAA0B,CAAC,CAAC;YACvE,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7C,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;gBAC1B,WAAoD,EAAzB,KAAA,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,EAAzB,cAAyB,EAAzB,IAAyB,EAAE;oBAA3C,YAAY;oBACnB,WAAwE,EAAlD,KAAA,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,EAAlD,cAAkD,EAAlD,IAAkD,EAAE;wBAA/D,OAAO;wBACR,WAAW,GAAG,UAAG,SAAS,cAAI,YAAY,cAAI,OAAO,CAAE,CAAC;wBACxD,OAAO,GAAG,OAAO,GAAG,YAAY,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;wBAC9H,WAAW,GAAG,UAAG,SAAS,cAAI,OAAO,cAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAE,CAAC;wBAC1E,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;qBAC7C;iBACJ;aACJ;;;;CACJ;AAED,eAAe,cAAc,CAAC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import fs from 'fs';
|
|
38
|
+
import path from 'path';
|
|
39
|
+
var access;
|
|
40
|
+
export function enableLogger(file, page) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
+
var suite, test, testName, logPathPerSuite;
|
|
43
|
+
var _this = this;
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
suite = file[1];
|
|
46
|
+
test = file.reverse()[0];
|
|
47
|
+
testName = "".concat(suite, " ").concat(test);
|
|
48
|
+
logPathPerSuite = path.join(process.cwd(), 'results-e2e/logs');
|
|
49
|
+
// Create folder per suite for error files
|
|
50
|
+
fs.mkdirSync(logPathPerSuite, { recursive: true });
|
|
51
|
+
// Create a writable stream for each file per test
|
|
52
|
+
access = fs.createWriteStream("".concat(logPathPerSuite, "/").concat(testName, ".log"));
|
|
53
|
+
process.stdout.write = process.stderr.write = access.write.bind(access);
|
|
54
|
+
// Write the GitHub link of the currently running test to the beginning of each log file
|
|
55
|
+
console.log("\n https://github.com/SPSCommerce/".concat(process.env.REPONAME, "/search?q=").concat(test));
|
|
56
|
+
// Listen for errors
|
|
57
|
+
page
|
|
58
|
+
.on('console', function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
59
|
+
var _i, _a, arg, _b, _c;
|
|
60
|
+
return __generator(this, function (_d) {
|
|
61
|
+
switch (_d.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
if (!(message.type() === 'error')) return [3 /*break*/, 5];
|
|
64
|
+
if (!(message.text() === 'JSHandle@error')) return [3 /*break*/, 4];
|
|
65
|
+
_i = 0, _a = message.args();
|
|
66
|
+
_d.label = 1;
|
|
67
|
+
case 1:
|
|
68
|
+
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
69
|
+
arg = _a[_i];
|
|
70
|
+
_c = (_b = console).log;
|
|
71
|
+
return [4 /*yield*/, arg.jsonValue()];
|
|
72
|
+
case 2:
|
|
73
|
+
_c.apply(_b, [_d.sent()]);
|
|
74
|
+
_d.label = 3;
|
|
75
|
+
case 3:
|
|
76
|
+
_i++;
|
|
77
|
+
return [3 /*break*/, 1];
|
|
78
|
+
case 4:
|
|
79
|
+
console.log("--Console-msg--".concat(message.type(), ": ").concat(message.text()));
|
|
80
|
+
_d.label = 5;
|
|
81
|
+
case 5: return [2 /*return*/];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}); })
|
|
85
|
+
.on('requestfailed', function (request) {
|
|
86
|
+
return console.log("--Failed-request--".concat(request.failure().errorText, ": ").concat(request.url()));
|
|
87
|
+
})
|
|
88
|
+
.on("pageerror", function (err) {
|
|
89
|
+
console.log("--Page-error--".concat(err.message));
|
|
90
|
+
})
|
|
91
|
+
.on('response', function (response) {
|
|
92
|
+
if (response.status() >= 400) {
|
|
93
|
+
console.log("--4XX/5XX-response--".concat(response.status(), ": ").concat(response.url()));
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return [2 /*return*/];
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export function disableLogger() {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
// Finish error writing
|
|
104
|
+
access && access.end();
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=loggerSetup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loggerSetup.js","sourceRoot":"","sources":["../helpers/loggerSetup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,IAAI,MAAW,CAAC;AAEhB,MAAM,UAAgB,YAAY,CAAC,IAAc,EAAE,IAAU;;;;;YAQnD,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAChB,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;YACzB,QAAQ,GAAG,UAAG,KAAK,cAAI,IAAI,CAAE,CAAC;YAC9B,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;YAErE,2CAA2C;YAC3C,EAAE,CAAC,SAAS,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAEnD,kDAAkD;YA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C/C,CAAC,CAAC;iBACD,EAAE,CAAC,UAAU,EAAE,UAAC,QAAQ;gBACrB,IAAI,QAAQ,CAAC,MAAM,EAAE,IAAI,GAAG,EAAE;oBAC1B,OAAO,CAAC,GAAG,CAAC,8BAAuB,QAAQ,CAAC,MAAM,EAAE,eAAK,QAAQ,CAAC,GAAG,EAAE,CAAE,CAAC,CAAC;iBAC9E;YACL,CAAC,CAAC,CAAA;YACN,sBAAO;;;CACV;AAED,MAAM,UAAgB,aAAa;;;YAC/B,uBAAuB;YACvB,MAAM,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;YACvB,sBAAO;;;CACV"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { test } from '@playwright/test';
|
|
2
|
+
import withMessage from '@alex_neo/jest-expect-message/dist/withMessage.js';
|
|
3
|
+
var expect = withMessage(test.expect);
|
|
4
|
+
var matchers = require('jest-extended');
|
|
5
|
+
expect.extend(matchers);
|
|
6
|
+
export default expect;
|
|
7
|
+
//# sourceMappingURL=matchersSetup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchersSetup.js","sourceRoot":"","sources":["../helpers/matchersSetup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,WAAW,MAAM,mDAAmD,CAAC;AAE5E,IAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAExC,IAAM,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAExB,eAAe,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spscommerce/e2e-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "An automation test framework which is based on Playwright.",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"types": "./lib/index.d.ts",
|
|
5
7
|
"scripts": {
|
|
6
|
-
"lint": "eslint ."
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"build": "tsc --incremental -p tsconfig.json"
|
|
7
10
|
},
|
|
8
11
|
"repository": {
|
|
9
12
|
"type": "git",
|
|
@@ -22,7 +25,7 @@
|
|
|
22
25
|
"license": "UNLICENSED",
|
|
23
26
|
"dependencies": {
|
|
24
27
|
"@alex_neo/jest-expect-message": "^1.0.5",
|
|
25
|
-
"@playwright/test": "^1.
|
|
28
|
+
"@playwright/test": "^1.22.0-alpha-apr-10-2022",
|
|
26
29
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
27
30
|
"@typescript-eslint/parser": "^4.33.0",
|
|
28
31
|
"eslint": "^7.32.0",
|
package/tsconfig.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
+
"include": ["./helpers"],
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"
|
|
4
|
-
"target": "es2021",
|
|
4
|
+
"target": "es5",
|
|
5
5
|
"module": "esnext",
|
|
6
6
|
"esModuleInterop": true,
|
|
7
7
|
"resolveJsonModule": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"declaration": true,
|
|
8
10
|
"moduleResolution": "node",
|
|
9
11
|
"forceConsistentCasingInFileNames": true,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"outDir": "lib"
|
|
12
14
|
}
|
|
13
|
-
}
|
|
15
|
+
}
|