@brillout/test-e2e 0.3.7 → 0.3.9
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/dist/Logs.d.ts +3 -1
- package/dist/Logs.js +14 -4
- package/dist/runTests.js +8 -6
- package/package.json +1 -1
package/dist/Logs.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { expectError };
|
|
|
2
2
|
export declare const Logs: {
|
|
3
3
|
add: typeof add;
|
|
4
4
|
flushLogs: typeof flushLogs;
|
|
5
|
+
logErrors: typeof logErrors;
|
|
5
6
|
clearLogs: typeof clearLogs;
|
|
6
7
|
hasErrorLogs: typeof hasErrorLogs;
|
|
7
8
|
flushEagerly: boolean;
|
|
@@ -13,8 +14,9 @@ declare type LogEntry = {
|
|
|
13
14
|
logTimestamp: string;
|
|
14
15
|
isNotFailure: boolean;
|
|
15
16
|
};
|
|
16
|
-
declare function hasErrorLogs(
|
|
17
|
+
declare function hasErrorLogs(failOnWarning: boolean): boolean;
|
|
17
18
|
declare function clearLogs(): void;
|
|
19
|
+
declare function logErrors(failOnWarning: boolean): void;
|
|
18
20
|
declare function flushLogs(): void;
|
|
19
21
|
declare function add({ logSource, logText }: {
|
|
20
22
|
logSource: LogSource;
|
package/dist/Logs.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.Logs = exports.expectError = void 0;
|
|
|
7
7
|
exports.Logs = {
|
|
8
8
|
add,
|
|
9
9
|
flushLogs,
|
|
10
|
+
logErrors,
|
|
10
11
|
clearLogs,
|
|
11
12
|
hasErrorLogs,
|
|
12
13
|
flushEagerly: false,
|
|
@@ -16,15 +17,19 @@ const picocolors_1 = __importDefault(require("picocolors"));
|
|
|
16
17
|
const getCurrentTest_1 = require("./getCurrentTest");
|
|
17
18
|
const getConfig_1 = require("./getConfig");
|
|
18
19
|
let logEntries = [];
|
|
19
|
-
function hasErrorLogs(
|
|
20
|
-
const
|
|
20
|
+
function hasErrorLogs(failOnWarning) {
|
|
21
|
+
const errorLogs = getErrorLogs(failOnWarning);
|
|
22
|
+
return errorLogs.length > 0;
|
|
23
|
+
}
|
|
24
|
+
function getErrorLogs(failOnWarning) {
|
|
25
|
+
const errorLogs = logEntries.filter(({ logSource, isNotFailure }) => {
|
|
21
26
|
if (isNotFailure) {
|
|
22
27
|
return;
|
|
23
28
|
}
|
|
24
29
|
if (logSource === 'run() failure') {
|
|
25
30
|
return true;
|
|
26
31
|
}
|
|
27
|
-
if (
|
|
32
|
+
if (failOnWarning && (logSource === 'Browser Warning' || logSource === 'stderr')) {
|
|
28
33
|
return true;
|
|
29
34
|
}
|
|
30
35
|
if (logSource === 'Browser Error') {
|
|
@@ -32,12 +37,17 @@ function hasErrorLogs(doNotFailOnWarning = false) {
|
|
|
32
37
|
}
|
|
33
38
|
return false;
|
|
34
39
|
});
|
|
35
|
-
return
|
|
40
|
+
return errorLogs;
|
|
36
41
|
}
|
|
37
42
|
function clearLogs() {
|
|
38
43
|
logEntries = [];
|
|
39
44
|
}
|
|
45
|
+
function logErrors(failOnWarning) {
|
|
46
|
+
const errorLogs = getErrorLogs(failOnWarning);
|
|
47
|
+
errorLogs.forEach((logEntry) => printLog(logEntry));
|
|
48
|
+
}
|
|
40
49
|
function flushLogs() {
|
|
50
|
+
console.log(picocolors_1.default.bold('vvvv ALL LOGS vvvv'));
|
|
41
51
|
logEntries.forEach((logEntry) => printLog(logEntry));
|
|
42
52
|
logEntries = [];
|
|
43
53
|
}
|
package/dist/runTests.js
CHANGED
|
@@ -56,14 +56,14 @@ async function runTests(browser) {
|
|
|
56
56
|
done(!!err);
|
|
57
57
|
testInfo.afterEach(!!err);
|
|
58
58
|
const { doNotFailOnWarning } = testInfo.runInfo;
|
|
59
|
-
const hasErrorLog = Logs_1.Logs.hasErrorLogs(doNotFailOnWarning);
|
|
59
|
+
const hasErrorLog = Logs_1.Logs.hasErrorLogs(!doNotFailOnWarning);
|
|
60
60
|
const isFailure = err || hasErrorLog;
|
|
61
61
|
if (isFailure) {
|
|
62
62
|
logTestsResult(false);
|
|
63
63
|
if (err) {
|
|
64
|
-
console.
|
|
64
|
+
console.log(err);
|
|
65
65
|
}
|
|
66
|
-
if (hasErrorLog) {
|
|
66
|
+
else if (hasErrorLog) {
|
|
67
67
|
logIsFailure(false, !doNotFailOnWarning);
|
|
68
68
|
}
|
|
69
69
|
Logs_1.Logs.flushLogs();
|
|
@@ -76,7 +76,7 @@ async function runTests(browser) {
|
|
|
76
76
|
await testInfo.terminateServer();
|
|
77
77
|
await page.close();
|
|
78
78
|
// Handle case that an error occured during `terminateServer()`
|
|
79
|
-
if (Logs_1.Logs.hasErrorLogs()) {
|
|
79
|
+
if (Logs_1.Logs.hasErrorLogs(true)) {
|
|
80
80
|
if ((0, utils_1.isWindows)()) {
|
|
81
81
|
// On Windows, the sever sometimes terminates with an exit code of `1`. I don't know why.
|
|
82
82
|
Logs_1.Logs.clearLogs();
|
|
@@ -132,11 +132,13 @@ function logTestsResult(success) {
|
|
|
132
132
|
console.log(`${failStyle(' FAIL ')} ${testInfo.testFile}`);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
function logIsFailure(isTermination,
|
|
135
|
+
function logIsFailure(isTermination, failOnWarning) {
|
|
136
136
|
console.log(picocolors_1.default.red(picocolors_1.default.bold([
|
|
137
137
|
'Test FAIL because encountered an error',
|
|
138
|
-
!
|
|
138
|
+
!failOnWarning ? '' : ' or warning',
|
|
139
139
|
!isTermination ? '' : ' during termination',
|
|
140
140
|
', see logs below.',
|
|
141
141
|
].join(''))));
|
|
142
|
+
console.log(picocolors_1.default.bold('vvvv FAIL LOG vvvv'));
|
|
143
|
+
Logs_1.Logs.logErrors(failOnWarning);
|
|
142
144
|
}
|