@brillout/test-e2e 0.4.5 → 0.4.7
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 +1 -1
- package/dist/Logs.js +3 -3
- package/dist/logError.d.ts +2 -0
- package/dist/logError.js +9 -0
- package/dist/runTests.d.ts +2 -0
- package/dist/runTests.js +14 -17
- package/dist/setup.js +5 -17
- package/dist/utils/assert.js +21 -1
- package/dist/utils/cliConfig.js +2 -1
- package/package.json +1 -1
package/dist/Logs.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const Logs: {
|
|
|
5
5
|
logErrors: typeof logErrors;
|
|
6
6
|
clearLogs: typeof clearLogs;
|
|
7
7
|
hasErrorLogs: typeof hasErrorLogs;
|
|
8
|
-
|
|
8
|
+
logEagerly: boolean;
|
|
9
9
|
};
|
|
10
10
|
declare type LogSource = 'stdout' | 'stderr' | 'Browser Error' | 'Browser Warning' | 'Browser Log' | 'Playwright' | 'run()' | 'run() failure' | 'test()' | 'Connection Error';
|
|
11
11
|
declare type LogEntry = {
|
package/dist/Logs.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.Logs = {
|
|
|
10
10
|
logErrors,
|
|
11
11
|
clearLogs,
|
|
12
12
|
hasErrorLogs,
|
|
13
|
-
|
|
13
|
+
logEagerly: false,
|
|
14
14
|
};
|
|
15
15
|
const utils_1 = require("./utils");
|
|
16
16
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
@@ -74,8 +74,8 @@ function add({ logSource, logText }) {
|
|
|
74
74
|
isNotFailure,
|
|
75
75
|
};
|
|
76
76
|
logEntries.push(logEntry);
|
|
77
|
-
if (exports.Logs.
|
|
78
|
-
|
|
77
|
+
if (exports.Logs.logEagerly) {
|
|
78
|
+
printLog(logEntry);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
function expectError(logFilter) {
|
package/dist/logError.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logError = void 0;
|
|
4
|
+
const logSection_1 = require("./logSection");
|
|
5
|
+
function logError(err, sectionTitle = 'ERROR') {
|
|
6
|
+
(0, logSection_1.logSection)(sectionTitle);
|
|
7
|
+
console.log(err);
|
|
8
|
+
}
|
|
9
|
+
exports.logError = logError;
|
package/dist/runTests.d.ts
CHANGED
package/dist/runTests.js
CHANGED
|
@@ -3,19 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.runTests = void 0;
|
|
6
|
+
exports.logFailure = exports.runTests = void 0;
|
|
7
7
|
const getCurrentTest_1 = require("./getCurrentTest");
|
|
8
8
|
const Logs_1 = require("./Logs");
|
|
9
9
|
const utils_1 = require("./utils");
|
|
10
10
|
const utils_2 = require("./utils");
|
|
11
11
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
12
12
|
const github_action_1 = require("./github-action");
|
|
13
|
-
const logSection_1 = require("./logSection");
|
|
14
13
|
const getCurrentTest_2 = require("./getCurrentTest");
|
|
15
14
|
const getBrowser_1 = require("./getBrowser");
|
|
16
15
|
const buildTs_1 = require("./buildTs");
|
|
17
16
|
const findTestFiles_1 = require("./findTestFiles");
|
|
18
17
|
const getConfig_1 = require("./getConfig");
|
|
18
|
+
const logError_1 = require("./logError");
|
|
19
19
|
async function runTests(filter) {
|
|
20
20
|
await (0, getConfig_1.loadConfig)();
|
|
21
21
|
const testFiles = await (0, findTestFiles_1.findTestFiles)(filter);
|
|
@@ -48,7 +48,7 @@ async function runTestFile(browser) {
|
|
|
48
48
|
testInfo.page = page;
|
|
49
49
|
// Set when user calls `skip()`
|
|
50
50
|
if (testInfo.skipped) {
|
|
51
|
-
|
|
51
|
+
logTestStatus(false);
|
|
52
52
|
(0, utils_1.assertUsage)(!testInfo.runInfo, 'You cannot call `run()` after calling `skip()`');
|
|
53
53
|
(0, utils_1.assertUsage)(testInfo.tests === undefined, 'You cannot call `test()` after calling `skip()`');
|
|
54
54
|
return;
|
|
@@ -73,8 +73,8 @@ async function runTestFile(browser) {
|
|
|
73
73
|
await testInfo.startServer();
|
|
74
74
|
}
|
|
75
75
|
catch (err) {
|
|
76
|
-
|
|
77
|
-
logError(err);
|
|
76
|
+
logFailure('an error occurred while starting the server');
|
|
77
|
+
(0, logError_1.logError)(err);
|
|
78
78
|
Logs_1.Logs.flushLogs();
|
|
79
79
|
await abort();
|
|
80
80
|
return;
|
|
@@ -100,11 +100,11 @@ async function runTestFile(browser) {
|
|
|
100
100
|
const isFailure = err || hasErrorLog;
|
|
101
101
|
if (isFailure) {
|
|
102
102
|
if (err) {
|
|
103
|
-
|
|
104
|
-
logError(err);
|
|
103
|
+
logFailure(`the test "${testDesc}" threw an error`);
|
|
104
|
+
(0, logError_1.logError)(err);
|
|
105
105
|
}
|
|
106
106
|
else if (hasErrorLog) {
|
|
107
|
-
|
|
107
|
+
logFailure(`${getErrorType(failOnWarning)} occurred while running the test "${testDesc}"`);
|
|
108
108
|
}
|
|
109
109
|
else {
|
|
110
110
|
(0, utils_1.assert)(false);
|
|
@@ -124,7 +124,7 @@ async function runTestFile(browser) {
|
|
|
124
124
|
if (Logs_1.Logs.hasErrorLogs(failOnWarning) &&
|
|
125
125
|
// See comments about taskkill in src/setup.ts
|
|
126
126
|
!(0, utils_1.isWindows)()) {
|
|
127
|
-
|
|
127
|
+
logFailure(`${getErrorType(failOnWarning)} occurred during server termination`);
|
|
128
128
|
Logs_1.Logs.logErrors(failOnWarning);
|
|
129
129
|
Logs_1.Logs.flushLogs();
|
|
130
130
|
await abort();
|
|
@@ -132,7 +132,7 @@ async function runTestFile(browser) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
Logs_1.Logs.clearLogs();
|
|
135
|
-
|
|
135
|
+
logTestStatus(true);
|
|
136
136
|
}
|
|
137
137
|
function getErrorType(failOnWarning) {
|
|
138
138
|
return !failOnWarning ? 'error(s)' : 'error(s)/warning(s)';
|
|
@@ -162,7 +162,7 @@ function runTest(testFn, testFunctionTimeout) {
|
|
|
162
162
|
})();
|
|
163
163
|
return promise;
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function logTestStatus(success) {
|
|
166
166
|
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
167
167
|
const { PASS, FAIL, WARN } = getStatusTags();
|
|
168
168
|
if (success) {
|
|
@@ -177,17 +177,14 @@ function logResult(success) {
|
|
|
177
177
|
console.log(`${FAIL} ${testInfo.testFile}`);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
function
|
|
181
|
-
|
|
180
|
+
function logFailure(reason) {
|
|
181
|
+
logTestStatus(false);
|
|
182
182
|
const { FAIL } = getStatusTags();
|
|
183
183
|
const color = (s) => picocolors_1.default.red(picocolors_1.default.bold(s));
|
|
184
184
|
const msg = `Test ${FAIL} because ${reason}, see below.`;
|
|
185
185
|
console.log(color(msg));
|
|
186
186
|
}
|
|
187
|
-
|
|
188
|
-
(0, logSection_1.logSection)('ERROR');
|
|
189
|
-
console.log(err);
|
|
190
|
-
}
|
|
187
|
+
exports.logFailure = logFailure;
|
|
191
188
|
function getStatusTags() {
|
|
192
189
|
const PASS = picocolors_1.default.bold(picocolors_1.default.bgGreen(picocolors_1.default.white(' PASS ')));
|
|
193
190
|
const FAIL = picocolors_1.default.bold(picocolors_1.default.bgRed(picocolors_1.default.white(' FAIL ')));
|
package/dist/setup.js
CHANGED
|
@@ -51,7 +51,7 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
|
|
|
51
51
|
serverUrl,
|
|
52
52
|
};
|
|
53
53
|
if (inspect) {
|
|
54
|
-
Logs_1.Logs.
|
|
54
|
+
Logs_1.Logs.logEagerly = true;
|
|
55
55
|
}
|
|
56
56
|
let runProcess = null;
|
|
57
57
|
testInfo.startServer = async () => {
|
|
@@ -362,10 +362,10 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
|
|
|
362
362
|
function assertNotExited(data) {
|
|
363
363
|
if (!procExited)
|
|
364
364
|
return;
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
(0, utils_2.assert)(false);
|
|
365
|
+
// Sometimes, a single white space is emitted after 'exit' has been emitted.
|
|
366
|
+
if (data.trim().length === 0)
|
|
367
|
+
return;
|
|
368
|
+
(0, utils_2.assert)(false, { data: data, dataLength: data.length });
|
|
369
369
|
}
|
|
370
370
|
function processHasExited() {
|
|
371
371
|
return procExited;
|
|
@@ -493,15 +493,3 @@ function getPort() {
|
|
|
493
493
|
(0, utils_2.assert)(/\d+/.test(port), { serverUrl });
|
|
494
494
|
return port;
|
|
495
495
|
}
|
|
496
|
-
function logDebugInfo(data) {
|
|
497
|
-
console.log('vvvvv DEBUG INFO vvvvv');
|
|
498
|
-
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
499
|
-
console.log('testInfo.hasStartedRunning', testInfo.hasStartedRunning);
|
|
500
|
-
console.log('testInfo.skipped', testInfo.skipped);
|
|
501
|
-
console.log('testInfo.runInfo', testInfo.runInfo);
|
|
502
|
-
console.log('testInfo.testFile', testInfo.testFile);
|
|
503
|
-
console.log('testInfo.testName', testInfo.testName);
|
|
504
|
-
console.log('data', data);
|
|
505
|
-
console.log('process.platform', process.platform);
|
|
506
|
-
console.log('^^^^^ DEBUG INFO ^^^^^');
|
|
507
|
-
}
|
package/dist/utils/assert.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.projectErrorPrefix = exports.getProjectError = exports.assertInfo = exports.assertWarning = exports.assertUsage = exports.assert = void 0;
|
|
4
|
+
const runTests_1 = require("../runTests");
|
|
4
5
|
const createErrorWithCleanStackTrace_1 = require("./createErrorWithCleanStackTrace");
|
|
5
6
|
const projectInfo_1 = require("./projectInfo");
|
|
7
|
+
const Logs_1 = require("../Logs");
|
|
8
|
+
const getCurrentTest_1 = require("../getCurrentTest");
|
|
9
|
+
const logSection_1 = require("../logSection");
|
|
10
|
+
const logError_1 = require("../logError");
|
|
6
11
|
const errorPrefix = `[${projectInfo_1.projectInfo.npmPackageName}]`;
|
|
7
12
|
exports.projectErrorPrefix = errorPrefix;
|
|
8
13
|
const internalErrorPrefix = `${errorPrefix}[Bug]`;
|
|
@@ -28,7 +33,12 @@ function assert(condition, debugInfo) {
|
|
|
28
33
|
`Do not hesitate to reach out as it makes ${projectInfo_1.projectInfo.projectName} more robust.`,
|
|
29
34
|
debugStr,
|
|
30
35
|
].join(' '), numberOfStackTraceLinesToRemove);
|
|
31
|
-
|
|
36
|
+
(0, runTests_1.logFailure)('a bug occurred in @brillout/test-e2e');
|
|
37
|
+
(0, logError_1.logError)(internalError, 'BUG');
|
|
38
|
+
logDebugInfo();
|
|
39
|
+
Logs_1.Logs.logErrors(true);
|
|
40
|
+
Logs_1.Logs.flushLogs();
|
|
41
|
+
throw new Error('Bug. See messages above.');
|
|
32
42
|
}
|
|
33
43
|
exports.assert = assert;
|
|
34
44
|
function assertUsage(condition, errorMessage) {
|
|
@@ -70,3 +80,13 @@ function assertInfo(condition, errorMessage) {
|
|
|
70
80
|
console.warn(`${infoPrefix} ${errorMessage}`);
|
|
71
81
|
}
|
|
72
82
|
exports.assertInfo = assertInfo;
|
|
83
|
+
function logDebugInfo() {
|
|
84
|
+
(0, logSection_1.logSection)('DEBUG INFO');
|
|
85
|
+
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
86
|
+
console.log('testInfo.hasStartedRunning', testInfo.hasStartedRunning);
|
|
87
|
+
console.log('testInfo.skipped', testInfo.skipped);
|
|
88
|
+
console.log('testInfo.runInfo', testInfo.runInfo);
|
|
89
|
+
console.log('testInfo.testFile', testInfo.testFile);
|
|
90
|
+
console.log('testInfo.testName', testInfo.testName);
|
|
91
|
+
console.log('process.platform', process.platform);
|
|
92
|
+
}
|
package/dist/utils/cliConfig.js
CHANGED
|
@@ -4,5 +4,6 @@ exports.cliConfig = void 0;
|
|
|
4
4
|
const cliArgs = process.argv.slice(2);
|
|
5
5
|
exports.cliConfig = {
|
|
6
6
|
debugEsbuild: cliArgs.includes('--debug-esbuild'),
|
|
7
|
-
inspect:
|
|
7
|
+
// To inspect a specific test: `$ touch examples/some-example/INSPECT`
|
|
8
|
+
inspect: cliArgs.includes('--inspect') || !!process.env.TEST_INSPECT,
|
|
8
9
|
};
|