@brillout/test-e2e 0.1.21 → 0.2.0
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 +6 -6
- package/dist/Logs.js +9 -12
- package/dist/cli.js +7 -0
- package/dist/getCurrentTest.d.ts +1 -0
- package/dist/runTests.js +26 -16
- package/dist/setup.d.ts +5 -8
- package/dist/setup.js +32 -35
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/platform.d.ts +8 -0
- package/dist/utils/platform.js +24 -0
- package/dist/utils/runCommand.d.ts +2 -2
- package/dist/utils/runCommand.js +1 -1
- package/package.json +1 -1
package/dist/Logs.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { expectError };
|
|
2
2
|
export declare const Logs: {
|
|
3
3
|
add: typeof add;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
flushLogs: typeof flushLogs;
|
|
5
|
+
clearLogs: typeof clearLogs;
|
|
6
|
+
hasErrorLogs: typeof hasErrorLogs;
|
|
7
7
|
flushEagerly: boolean;
|
|
8
8
|
};
|
|
9
9
|
declare type LogSource = 'stdout' | 'stderr' | 'Browser Error' | 'Browser Warning' | 'Browser Log' | 'Playwright' | 'run()' | 'run() failure' | 'test()' | 'Connection Error';
|
|
@@ -13,9 +13,9 @@ declare type LogEntry = {
|
|
|
13
13
|
logTimestamp: string;
|
|
14
14
|
isNotFailure: boolean;
|
|
15
15
|
};
|
|
16
|
-
declare function
|
|
17
|
-
declare function
|
|
18
|
-
declare function
|
|
16
|
+
declare function hasErrorLogs(onlyFailOnBrowserError?: boolean): boolean;
|
|
17
|
+
declare function clearLogs(): void;
|
|
18
|
+
declare function flushLogs(): void;
|
|
19
19
|
declare function add({ logSource, logText }: {
|
|
20
20
|
logSource: LogSource;
|
|
21
21
|
logText: string;
|
package/dist/Logs.js
CHANGED
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Logs = exports.expectError = void 0;
|
|
7
7
|
exports.Logs = {
|
|
8
8
|
add,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
flushLogs,
|
|
10
|
+
clearLogs,
|
|
11
|
+
hasErrorLogs,
|
|
12
12
|
flushEagerly: false,
|
|
13
13
|
};
|
|
14
14
|
const utils_1 = require("./utils");
|
|
@@ -16,8 +16,7 @@ const picocolors_1 = __importDefault(require("picocolors"));
|
|
|
16
16
|
const getCurrentTest_1 = require("./getCurrentTest");
|
|
17
17
|
const getConfig_1 = require("./getConfig");
|
|
18
18
|
let logEntries = [];
|
|
19
|
-
|
|
20
|
-
function hasError(onlyFailOnBrowserError = false) {
|
|
19
|
+
function hasErrorLogs(onlyFailOnBrowserError = false) {
|
|
21
20
|
const logErrors = logEntries.filter(({ logSource, isNotFailure }) => {
|
|
22
21
|
if (isNotFailure) {
|
|
23
22
|
return;
|
|
@@ -35,13 +34,12 @@ function hasError(onlyFailOnBrowserError = false) {
|
|
|
35
34
|
});
|
|
36
35
|
return logErrors.length > 0;
|
|
37
36
|
}
|
|
38
|
-
function
|
|
37
|
+
function clearLogs() {
|
|
39
38
|
logEntries = [];
|
|
40
|
-
logEntriesNotPrinted = [];
|
|
41
39
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
function flushLogs() {
|
|
41
|
+
logEntries.forEach((logEntry) => printLog(logEntry));
|
|
42
|
+
logEntries = [];
|
|
45
43
|
}
|
|
46
44
|
function add({ logSource, logText }) {
|
|
47
45
|
const logTimestamp = getTimestamp();
|
|
@@ -61,10 +59,9 @@ function add({ logSource, logText }) {
|
|
|
61
59
|
logTimestamp,
|
|
62
60
|
isNotFailure,
|
|
63
61
|
};
|
|
64
|
-
logEntriesNotPrinted.push(logEntry);
|
|
65
62
|
logEntries.push(logEntry);
|
|
66
63
|
if (exports.Logs.flushEagerly) {
|
|
67
|
-
|
|
64
|
+
flushLogs();
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
67
|
function expectError(logFilter) {
|
package/dist/cli.js
CHANGED
|
@@ -7,8 +7,10 @@ const source_map_support_1 = __importDefault(require("source-map-support"));
|
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
8
|
const runTestSuites_1 = require("./runTestSuites");
|
|
9
9
|
const buildTs_1 = require("./buildTs");
|
|
10
|
+
const Logs_1 = require("./Logs");
|
|
10
11
|
initSourceMap();
|
|
11
12
|
initPromiseRejectionHandler();
|
|
13
|
+
initUserExitHandler();
|
|
12
14
|
cli();
|
|
13
15
|
function cli() {
|
|
14
16
|
const filter = (0, utils_1.findFilesParseCliArgs)();
|
|
@@ -20,6 +22,11 @@ function initPromiseRejectionHandler() {
|
|
|
20
22
|
process.exit(1);
|
|
21
23
|
});
|
|
22
24
|
}
|
|
25
|
+
function initUserExitHandler() {
|
|
26
|
+
process.on('SIGINT', function () {
|
|
27
|
+
Logs_1.Logs.flushLogs();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
23
30
|
function initSourceMap() {
|
|
24
31
|
source_map_support_1.default.install({
|
|
25
32
|
retrieveSourceMap: function (source) {
|
package/dist/getCurrentTest.d.ts
CHANGED
package/dist/runTests.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.runTests = void 0;
|
|
4
7
|
const getCurrentTest_1 = require("./getCurrentTest");
|
|
5
8
|
const Logs_1 = require("./Logs");
|
|
6
9
|
const utils_1 = require("./utils");
|
|
7
|
-
const picocolors_1 = require("picocolors");
|
|
8
|
-
const logsContainError_errMsg = '
|
|
10
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
11
|
+
const logsContainError_errMsg = (isTermination) => [picocolors_1.default.bold('Encountered an error or warning'), !isTermination ? '' : ' during termination', ', see logs below.'].join('');
|
|
9
12
|
async function runTests(browser) {
|
|
10
13
|
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
11
14
|
if (utils_1.isTTY) {
|
|
@@ -35,7 +38,7 @@ async function runTests(browser) {
|
|
|
35
38
|
catch (err) {
|
|
36
39
|
logTestsResult(false);
|
|
37
40
|
console.log(err);
|
|
38
|
-
Logs_1.Logs.
|
|
41
|
+
Logs_1.Logs.flushLogs();
|
|
39
42
|
process.exit(1);
|
|
40
43
|
}
|
|
41
44
|
for (const { testDesc, testFn } of testInfo.tests) {
|
|
@@ -53,7 +56,7 @@ async function runTests(browser) {
|
|
|
53
56
|
}
|
|
54
57
|
done(!!err);
|
|
55
58
|
testInfo.afterEach(!!err);
|
|
56
|
-
const hasErrorLog = Logs_1.Logs.
|
|
59
|
+
const hasErrorLog = Logs_1.Logs.hasErrorLogs(testInfo.runInfo.onlyFailOnBrowserError);
|
|
57
60
|
const isFailure = err || hasErrorLog;
|
|
58
61
|
if (isFailure) {
|
|
59
62
|
logTestsResult(false);
|
|
@@ -61,21 +64,28 @@ async function runTests(browser) {
|
|
|
61
64
|
console.error(err);
|
|
62
65
|
}
|
|
63
66
|
if (hasErrorLog) {
|
|
64
|
-
console.log(
|
|
67
|
+
console.log(logsContainError_errMsg(false));
|
|
65
68
|
}
|
|
66
|
-
Logs_1.Logs.
|
|
69
|
+
Logs_1.Logs.flushLogs();
|
|
67
70
|
process.exit(1);
|
|
68
71
|
}
|
|
69
72
|
else {
|
|
70
|
-
Logs_1.Logs.
|
|
73
|
+
Logs_1.Logs.clearLogs();
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
await testInfo.terminateServer();
|
|
74
77
|
await page.close();
|
|
75
78
|
// Handle case that an error occured during `terminateServer()`
|
|
76
|
-
if (Logs_1.Logs.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
if (Logs_1.Logs.hasErrorLogs()) {
|
|
80
|
+
if ((0, utils_1.isWindows)()) {
|
|
81
|
+
// On Windows, the sever sometimes terminates with an exit code of `1`. I don't know why.
|
|
82
|
+
Logs_1.Logs.clearLogs();
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
console.log(logsContainError_errMsg(true));
|
|
86
|
+
Logs_1.Logs.flushLogs();
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
79
89
|
}
|
|
80
90
|
logTestsResult(true);
|
|
81
91
|
}
|
|
@@ -107,18 +117,18 @@ function runTest(testFn, testFunctionTimeout) {
|
|
|
107
117
|
}
|
|
108
118
|
function logTestsResult(success) {
|
|
109
119
|
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
110
|
-
const passStyle = (t) =>
|
|
111
|
-
const failStyle = (t) =>
|
|
112
|
-
const skipStyle = (t) =>
|
|
120
|
+
const passStyle = (t) => picocolors_1.default.bold(picocolors_1.default.bgGreen(t));
|
|
121
|
+
const failStyle = (t) => picocolors_1.default.bold(picocolors_1.default.bgRed(t));
|
|
122
|
+
const skipStyle = (t) => picocolors_1.default.bold(picocolors_1.default.bgYellow(t));
|
|
113
123
|
if (success) {
|
|
114
124
|
(0, utils_1.assert)(!testInfo.skipped);
|
|
115
|
-
console.log(`${passStyle('PASS')} ${testInfo.testFile}`);
|
|
125
|
+
console.log(`${passStyle(' PASS ')} ${testInfo.testFile}`);
|
|
116
126
|
return;
|
|
117
127
|
}
|
|
118
128
|
if (testInfo.skipped) {
|
|
119
|
-
console.log(`${skipStyle('WARN')} ${testInfo.testFile} (${testInfo.skipped})`);
|
|
129
|
+
console.log(`${skipStyle(' WARN ')} ${testInfo.testFile} (${testInfo.skipped})`);
|
|
120
130
|
}
|
|
121
131
|
else {
|
|
122
|
-
console.log(`${failStyle('FAIL')} ${testInfo.testFile}`);
|
|
132
|
+
console.log(`${failStyle(' FAIL ')} ${testInfo.testFile}`);
|
|
123
133
|
}
|
|
124
134
|
}
|
package/dist/setup.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sleep } from './utils';
|
|
1
|
+
import { sleep, isWindows, isLinux, isGithubAction, isMac } from './utils';
|
|
2
2
|
import fetch_ from 'node-fetch';
|
|
3
3
|
export { partRegex } from '@brillout/part-regex';
|
|
4
4
|
export { autoRetry };
|
|
@@ -13,17 +13,17 @@ export { isLinux };
|
|
|
13
13
|
export { isWindows };
|
|
14
14
|
export { isMac };
|
|
15
15
|
export { sleep };
|
|
16
|
-
export
|
|
17
|
-
export declare const urlBaseChange: (url: string) => string;
|
|
16
|
+
export { getServerUrl };
|
|
18
17
|
export { editFile, editFileRevert } from './editFile';
|
|
19
18
|
declare function skip(reason: string): void;
|
|
20
|
-
declare function run(cmd: string, { additionalTimeout, serverIsReadyMessage, serverIsReadyDelay, inspect, cwd, onlyFailOnBrowserError, }?: {
|
|
19
|
+
declare function run(cmd: string, { additionalTimeout, serverIsReadyMessage, serverIsReadyDelay, inspect, cwd, onlyFailOnBrowserError, serverUrl, }?: {
|
|
21
20
|
additionalTimeout?: number;
|
|
22
21
|
serverIsReadyMessage?: string;
|
|
23
22
|
serverIsReadyDelay?: number;
|
|
24
23
|
inspect?: boolean;
|
|
25
24
|
cwd?: string;
|
|
26
25
|
onlyFailOnBrowserError?: boolean;
|
|
26
|
+
serverUrl?: string;
|
|
27
27
|
}): void;
|
|
28
28
|
declare function autoRetry(test: () => void | Promise<void>, { timeout }?: {
|
|
29
29
|
timeout?: number;
|
|
@@ -31,7 +31,4 @@ declare function autoRetry(test: () => void | Promise<void>, { timeout }?: {
|
|
|
31
31
|
declare function fetchHtml(pathname: string): Promise<string>;
|
|
32
32
|
declare function fetch(...args: Parameters<typeof fetch_>): Promise<import("node-fetch").Response>;
|
|
33
33
|
declare function isMinNodeVersion(minNodeVersion: 14): boolean;
|
|
34
|
-
declare function
|
|
35
|
-
declare function isLinux(): boolean;
|
|
36
|
-
declare function isMac(): boolean;
|
|
37
|
-
declare function isGithubAction(): boolean;
|
|
34
|
+
declare function getServerUrl(): string;
|
package/dist/setup.js
CHANGED
|
@@ -3,11 +3,15 @@ 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.editFileRevert = exports.editFile = exports.
|
|
6
|
+
exports.editFileRevert = exports.editFile = exports.getServerUrl = exports.sleep = exports.isMac = exports.isWindows = exports.isLinux = exports.isGithubAction = exports.isMinNodeVersion = exports.skip = exports.run = exports.expectError = exports.fetch = exports.fetchHtml = exports.autoRetry = exports.partRegex = void 0;
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const utils_1 = require("./utils");
|
|
10
10
|
Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return utils_1.sleep; } });
|
|
11
|
+
Object.defineProperty(exports, "isWindows", { enumerable: true, get: function () { return utils_1.isWindows; } });
|
|
12
|
+
Object.defineProperty(exports, "isLinux", { enumerable: true, get: function () { return utils_1.isLinux; } });
|
|
13
|
+
Object.defineProperty(exports, "isGithubAction", { enumerable: true, get: function () { return utils_1.isGithubAction; } });
|
|
14
|
+
Object.defineProperty(exports, "isMac", { enumerable: true, get: function () { return utils_1.isMac; } });
|
|
11
15
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
12
16
|
const utils_2 = require("./utils");
|
|
13
17
|
const Logs_1 = require("./Logs");
|
|
@@ -19,15 +23,13 @@ var part_regex_1 = require("@brillout/part-regex");
|
|
|
19
23
|
Object.defineProperty(exports, "partRegex", { enumerable: true, get: function () { return part_regex_1.partRegex; } });
|
|
20
24
|
var Logs_2 = require("./Logs");
|
|
21
25
|
Object.defineProperty(exports, "expectError", { enumerable: true, get: function () { return Logs_2.expectError; } });
|
|
22
|
-
exports.urlBase = 'http://localhost:3000';
|
|
23
|
-
const urlBaseChange = (url) => (exports.urlBase = url);
|
|
24
|
-
exports.urlBaseChange = urlBaseChange;
|
|
25
26
|
var editFile_2 = require("./editFile");
|
|
26
27
|
Object.defineProperty(exports, "editFile", { enumerable: true, get: function () { return editFile_2.editFile; } });
|
|
27
28
|
Object.defineProperty(exports, "editFileRevert", { enumerable: true, get: function () { return editFile_2.editFileRevert; } });
|
|
29
|
+
const serverUrlDefault = 'http://localhost:3000';
|
|
28
30
|
const TIMEOUT_NPM_SCRIPT = 2 * 60 * 1000;
|
|
29
|
-
const TIMEOUT_TEST_FUNCTION = 60 * 1000 * (!isGithubAction() ? 1 : isWindows() ? 5 : 3);
|
|
30
|
-
const TIMEOUT_PROCESS_TERMINATION = 10 * 1000 * (!isGithubAction() ? 1 : isLinux() ? 1 : 4);
|
|
31
|
+
const TIMEOUT_TEST_FUNCTION = 60 * 1000 * (!(0, utils_1.isGithubAction)() ? 1 : (0, utils_1.isWindows)() ? 5 : 3);
|
|
32
|
+
const TIMEOUT_PROCESS_TERMINATION = 10 * 1000 * (!(0, utils_1.isGithubAction)() ? 1 : (0, utils_1.isLinux)() ? 1 : 4);
|
|
31
33
|
const TIMEOUT_AUTORETRY = TIMEOUT_TEST_FUNCTION / 2;
|
|
32
34
|
const TIMEOUT_PLAYWRIGHT = TIMEOUT_TEST_FUNCTION / 2;
|
|
33
35
|
function skip(reason) {
|
|
@@ -37,7 +39,7 @@ function skip(reason) {
|
|
|
37
39
|
exports.skip = skip;
|
|
38
40
|
function run(cmd, {
|
|
39
41
|
//baseUrl = '',
|
|
40
|
-
additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect = utils_1.cliConfig.inspect, cwd, onlyFailOnBrowserError = false, } = {}) {
|
|
42
|
+
additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect = utils_1.cliConfig.inspect, cwd, onlyFailOnBrowserError = false, serverUrl = serverUrlDefault, } = {}) {
|
|
41
43
|
additionalTimeout += serverIsReadyDelay;
|
|
42
44
|
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
43
45
|
testInfo.runInfo = {
|
|
@@ -49,6 +51,7 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
|
|
|
49
51
|
serverIsReadyDelay,
|
|
50
52
|
inspect,
|
|
51
53
|
onlyFailOnBrowserError,
|
|
54
|
+
serverUrl,
|
|
52
55
|
};
|
|
53
56
|
if (inspect) {
|
|
54
57
|
Logs_1.Logs.flushEagerly = true;
|
|
@@ -172,9 +175,11 @@ async function start() {
|
|
|
172
175
|
await terminate();
|
|
173
176
|
rejectServerStart(new Error(errMsg));
|
|
174
177
|
}, timeoutTotal);
|
|
175
|
-
// Kill any process that listens to port
|
|
176
|
-
if (!process.env.CI && isLinux()) {
|
|
177
|
-
|
|
178
|
+
// Kill any process that listens to the server port
|
|
179
|
+
if (!process.env.CI && (0, utils_1.isLinux)()) {
|
|
180
|
+
const port = getPort();
|
|
181
|
+
(0, utils_2.assert)(/\d+/.test(port));
|
|
182
|
+
await (0, utils_1.runCommand)(`fuser -k ${port}/tcp`, { swallowError: true, timeout: 10 * 1000 });
|
|
178
183
|
}
|
|
179
184
|
const { terminate, processHasExited } = execRunScript({
|
|
180
185
|
async onFailure(err) {
|
|
@@ -216,7 +221,7 @@ function stopProcess({ proc, cwd, cmd, signal, }) {
|
|
|
216
221
|
reject = _reject;
|
|
217
222
|
});
|
|
218
223
|
const onProcessClose = (code) => {
|
|
219
|
-
if (code === 0 || code === null || (code === 1 && isWindows())) {
|
|
224
|
+
if (code === 0 || code === null || (code === 1 && (0, utils_1.isWindows)())) {
|
|
220
225
|
resolve();
|
|
221
226
|
}
|
|
222
227
|
else {
|
|
@@ -225,7 +230,7 @@ function stopProcess({ proc, cwd, cmd, signal, }) {
|
|
|
225
230
|
};
|
|
226
231
|
proc.on('close', onProcessClose);
|
|
227
232
|
proc.on('exit', onProcessClose);
|
|
228
|
-
if (isWindows()) {
|
|
233
|
+
if ((0, utils_1.isWindows)()) {
|
|
229
234
|
// - https://github.com/nodejs/node/issues/3617#issuecomment-377731194
|
|
230
235
|
// - https://stackoverflow.com/questions/23706055/why-can-i-not-kill-my-child-process-in-nodejs-on-windows/28163919#28163919
|
|
231
236
|
(0, child_process_1.spawn)('taskkill', ['/pid', String(proc.pid), '/f', '/t'], {
|
|
@@ -268,7 +273,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
|
|
|
268
273
|
const { cwd, cmd } = getRunInfo();
|
|
269
274
|
let [command, ...args] = cmd.split(' ');
|
|
270
275
|
let detached = true;
|
|
271
|
-
if (isWindows()) {
|
|
276
|
+
if ((0, utils_1.isWindows)()) {
|
|
272
277
|
detached = false;
|
|
273
278
|
if (command === 'npm' || command === 'pnpm') {
|
|
274
279
|
command = command + '.cmd';
|
|
@@ -319,7 +324,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
|
|
|
319
324
|
procExited = true;
|
|
320
325
|
(0, utils_2.assert)(getRunInfo().cmd === cmd);
|
|
321
326
|
const exitIsPossible = onExit();
|
|
322
|
-
const isSuccessCode = [0, null].includes(code) || (isWindows() && code === 1);
|
|
327
|
+
const isSuccessCode = [0, null].includes(code) || ((0, utils_1.isWindows)() && code === 1);
|
|
323
328
|
const isExpected = isSuccessCode && exitIsPossible;
|
|
324
329
|
if (!isExpected) {
|
|
325
330
|
const errMsg = `Unexpected premature process termination, exit code: ${code}`;
|
|
@@ -397,7 +402,7 @@ async function autoRetry(test, { timeout = TIMEOUT_AUTORETRY } = {}) {
|
|
|
397
402
|
}
|
|
398
403
|
exports.autoRetry = autoRetry;
|
|
399
404
|
async function fetchHtml(pathname) {
|
|
400
|
-
const response = await fetch(
|
|
405
|
+
const response = await fetch(getServerUrl() + pathname);
|
|
401
406
|
const html = await response.text();
|
|
402
407
|
return html;
|
|
403
408
|
}
|
|
@@ -444,28 +449,20 @@ function isMinNodeVersion(minNodeVersion) {
|
|
|
444
449
|
return major >= minNodeVersion;
|
|
445
450
|
}
|
|
446
451
|
exports.isMinNodeVersion = isMinNodeVersion;
|
|
447
|
-
function isWindows() {
|
|
448
|
-
return process.platform === 'win32';
|
|
449
|
-
}
|
|
450
|
-
exports.isWindows = isWindows;
|
|
451
|
-
function isLinux() {
|
|
452
|
-
return process.platform === 'linux';
|
|
453
|
-
}
|
|
454
|
-
exports.isLinux = isLinux;
|
|
455
|
-
function isMac() {
|
|
456
|
-
if (process.platform === 'darwin') {
|
|
457
|
-
return true;
|
|
458
|
-
}
|
|
459
|
-
(0, utils_2.assert)(isLinux() || isWindows());
|
|
460
|
-
return false;
|
|
461
|
-
}
|
|
462
|
-
exports.isMac = isMac;
|
|
463
|
-
function isGithubAction() {
|
|
464
|
-
return !!process.env.CI;
|
|
465
|
-
}
|
|
466
|
-
exports.isGithubAction = isGithubAction;
|
|
467
452
|
function getCwd() {
|
|
468
453
|
const { testFile } = (0, getCurrentTest_1.getCurrentTest)();
|
|
469
454
|
const cwd = (0, path_1.dirname)(testFile);
|
|
470
455
|
return cwd;
|
|
471
456
|
}
|
|
457
|
+
function getServerUrl() {
|
|
458
|
+
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
459
|
+
const serverUrl = testInfo.runInfo?.serverUrl;
|
|
460
|
+
return serverUrl;
|
|
461
|
+
}
|
|
462
|
+
exports.getServerUrl = getServerUrl;
|
|
463
|
+
function getPort() {
|
|
464
|
+
const serverUrl = getServerUrl();
|
|
465
|
+
const port = serverUrl.split(':').slice(-1)[0].split('/')[0];
|
|
466
|
+
(0, utils_2.assert)(/\d+/.test(port), { serverUrl });
|
|
467
|
+
return port;
|
|
468
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isMac = exports.isWindows = exports.isLinux = exports.isGithubAction = void 0;
|
|
4
|
+
const assert_1 = require("./assert");
|
|
5
|
+
function isWindows() {
|
|
6
|
+
return process.platform === 'win32';
|
|
7
|
+
}
|
|
8
|
+
exports.isWindows = isWindows;
|
|
9
|
+
function isLinux() {
|
|
10
|
+
return process.platform === 'linux';
|
|
11
|
+
}
|
|
12
|
+
exports.isLinux = isLinux;
|
|
13
|
+
function isMac() {
|
|
14
|
+
if (process.platform === 'darwin') {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
(0, assert_1.assert)(isLinux() || isWindows());
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
exports.isMac = isMac;
|
|
21
|
+
function isGithubAction() {
|
|
22
|
+
return !!process.env.CI;
|
|
23
|
+
}
|
|
24
|
+
exports.isGithubAction = isGithubAction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { runCommand };
|
|
2
|
-
declare function runCommand(cmd: string, { swallowError, timeout, cwd }?: {
|
|
3
|
-
swallowError?:
|
|
2
|
+
declare function runCommand(cmd: string, { swallowError, timeout, cwd, }?: {
|
|
3
|
+
swallowError?: boolean;
|
|
4
4
|
timeout?: number;
|
|
5
5
|
cwd?: string;
|
|
6
6
|
}): Promise<string>;
|
package/dist/utils/runCommand.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runCommand = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
|
-
function runCommand(cmd, { swallowError, timeout = 5000, cwd } = {}) {
|
|
5
|
+
function runCommand(cmd, { swallowError = false, timeout = 5000, cwd = process.cwd(), } = {}) {
|
|
6
6
|
const { promise, resolvePromise } = genPromise();
|
|
7
7
|
const t = setTimeout(() => {
|
|
8
8
|
console.error(`Command call \`${cmd}\` timeout [${timeout / 1000} seconds][${cwd}].`);
|