@brillout/test-e2e 0.1.12 → 0.1.14
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 -3
- package/dist/Logs.js +7 -4
- package/dist/runTests.js +7 -8
- package/dist/setup.js +9 -1
- package/package.json +1 -1
package/dist/Logs.d.ts
CHANGED
|
@@ -3,17 +3,17 @@ export declare const Logs: {
|
|
|
3
3
|
add: typeof add;
|
|
4
4
|
flush: typeof flush;
|
|
5
5
|
clear: typeof clear;
|
|
6
|
-
|
|
6
|
+
hasError: typeof hasError;
|
|
7
7
|
flushEagerly: boolean;
|
|
8
8
|
};
|
|
9
|
-
declare type LogSource = 'stdout' | 'stderr' | 'Browser Error' | 'Browser Log' | 'Playwright' | 'run()' | 'test()' | 'Connection Error';
|
|
9
|
+
declare type LogSource = 'stdout' | 'stderr' | 'Browser Error' | 'Browser Warning' | 'Browser Log' | 'Playwright' | 'run()' | 'test()' | 'Connection Error';
|
|
10
10
|
declare type LogEntry = {
|
|
11
11
|
logSource: LogSource;
|
|
12
12
|
logText: string;
|
|
13
13
|
logTimestamp: string;
|
|
14
14
|
isExpectedError: boolean;
|
|
15
15
|
};
|
|
16
|
-
declare function
|
|
16
|
+
declare function hasError(): boolean;
|
|
17
17
|
declare function clear(): void;
|
|
18
18
|
declare function flush(): void;
|
|
19
19
|
declare function add({ logSource, logText }: {
|
package/dist/Logs.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.Logs = {
|
|
|
8
8
|
add,
|
|
9
9
|
flush,
|
|
10
10
|
clear,
|
|
11
|
-
|
|
11
|
+
hasError,
|
|
12
12
|
flushEagerly: false,
|
|
13
13
|
};
|
|
14
14
|
const utils_1 = require("./utils");
|
|
@@ -16,8 +16,9 @@ const picocolors_1 = __importDefault(require("picocolors"));
|
|
|
16
16
|
const getCurrentTest_1 = require("./getCurrentTest");
|
|
17
17
|
let logEntries = [];
|
|
18
18
|
let logEntriesNotPrinted = [];
|
|
19
|
-
function
|
|
20
|
-
|
|
19
|
+
function hasError() {
|
|
20
|
+
const logErrors = logEntries.filter(({ logSource, isExpectedError }) => (logSource === 'Browser Error' || logSource === 'Browser Warning' || logSource === 'stderr') && !isExpectedError);
|
|
21
|
+
return logErrors.length > 0;
|
|
21
22
|
}
|
|
22
23
|
function clear() {
|
|
23
24
|
logEntries = [];
|
|
@@ -85,11 +86,13 @@ function colorize(logSource) {
|
|
|
85
86
|
const { bold } = picocolors_1.default;
|
|
86
87
|
if (logSource === 'stderr' || logSource === 'Browser Error' || logSource === 'Connection Error')
|
|
87
88
|
return bold(picocolors_1.default.red(logSource));
|
|
89
|
+
if (logSource === 'Browser Warning')
|
|
90
|
+
return bold(picocolors_1.default.yellow(logSource));
|
|
88
91
|
if (logSource === 'stdout' || logSource === 'Browser Log')
|
|
89
92
|
return bold(picocolors_1.default.blue(logSource));
|
|
90
93
|
if (logSource === 'Playwright')
|
|
91
94
|
return bold(picocolors_1.default.magenta(logSource));
|
|
92
95
|
if (logSource === 'run()' || logSource === 'test()')
|
|
93
|
-
return bold(picocolors_1.default.
|
|
96
|
+
return bold(picocolors_1.default.cyan(logSource));
|
|
94
97
|
(0, utils_1.assert)(false);
|
|
95
98
|
}
|
package/dist/runTests.js
CHANGED
|
@@ -15,9 +15,9 @@ async function runTests(browser) {
|
|
|
15
15
|
testInfo.page = page;
|
|
16
16
|
// Set when user calls `skip()`
|
|
17
17
|
if (testInfo.skipped) {
|
|
18
|
+
logTestsResult(false);
|
|
18
19
|
(0, utils_1.assertUsage)(!testInfo.runInfo, 'You cannot call `run()` after calling `skip()`');
|
|
19
20
|
(0, utils_1.assertUsage)(testInfo.tests === undefined, 'You cannot call `test()` after calling `skip()`');
|
|
20
|
-
logTestsResult(false);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
// Set when user calls `run()`
|
|
@@ -32,9 +32,9 @@ async function runTests(browser) {
|
|
|
32
32
|
await testInfo.startServer();
|
|
33
33
|
}
|
|
34
34
|
catch (err) {
|
|
35
|
+
logTestsResult(false);
|
|
35
36
|
console.log(err);
|
|
36
37
|
Logs_1.Logs.flush();
|
|
37
|
-
logTestsResult(false);
|
|
38
38
|
process.exit(1);
|
|
39
39
|
}
|
|
40
40
|
for (const { testDesc, testFn } of testInfo.tests) {
|
|
@@ -52,18 +52,17 @@ async function runTests(browser) {
|
|
|
52
52
|
}
|
|
53
53
|
done(!!err);
|
|
54
54
|
testInfo.afterEach(!!err);
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const isFailure = err || browserThrewError;
|
|
55
|
+
const hasErrorLog = Logs_1.Logs.hasError();
|
|
56
|
+
const isFailure = err || hasErrorLog;
|
|
58
57
|
if (isFailure) {
|
|
58
|
+
logTestsResult(false);
|
|
59
59
|
if (err) {
|
|
60
60
|
console.error(err);
|
|
61
61
|
}
|
|
62
|
-
if (
|
|
63
|
-
console.log(new Error('The browser threw one or more error'));
|
|
62
|
+
if (hasErrorLog) {
|
|
63
|
+
console.log(new Error('The browser/server threw/logged one or more error, see logs below.'));
|
|
64
64
|
}
|
|
65
65
|
Logs_1.Logs.flush();
|
|
66
|
-
logTestsResult(false);
|
|
67
66
|
process.exit(1);
|
|
68
67
|
}
|
|
69
68
|
else {
|
package/dist/setup.js
CHANGED
|
@@ -90,7 +90,15 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
|
|
|
90
90
|
function onConsole(msg) {
|
|
91
91
|
const type = msg.type();
|
|
92
92
|
Logs_1.Logs.add({
|
|
93
|
-
logSource:
|
|
93
|
+
logSource: (() => {
|
|
94
|
+
if (type === 'error') {
|
|
95
|
+
return 'Browser Error';
|
|
96
|
+
}
|
|
97
|
+
if (type === 'warning') {
|
|
98
|
+
return 'Browser Warning';
|
|
99
|
+
}
|
|
100
|
+
return 'Browser Log';
|
|
101
|
+
})(),
|
|
94
102
|
logText: JSON.stringify({
|
|
95
103
|
type,
|
|
96
104
|
text: msg.text(),
|