@brillout/test-e2e 0.5.29 → 0.5.31
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/bin.js +1 -1
- package/dist/Logs/isTolerateError.d.ts +2 -2
- package/dist/Logs/isTolerateError.js +5 -11
- package/dist/Logs.d.ts +2 -2
- package/dist/Logs.js +26 -32
- package/dist/TIMEOUTS.js +6 -9
- package/dist/autoRetry.js +5 -8
- package/dist/buildTs.js +10 -16
- package/dist/chai/JestChaiExpect.d.ts +1 -1
- package/dist/chai/JestChaiExpect.js +1 -5
- package/dist/chai/expect.d.ts +1 -1
- package/dist/chai/expect.js +4 -30
- package/dist/chai/types.d.ts +4 -4
- package/dist/chai/types.js +1 -2
- package/dist/cli.js +13 -18
- package/dist/editFile.js +18 -22
- package/dist/fetch.d.ts +2 -2
- package/dist/fetch.js +20 -16
- package/dist/findTestFiles.d.ts +1 -1
- package/dist/findTestFiles.js +6 -9
- package/dist/getBrowser.js +9 -12
- package/dist/getConfig.d.ts +1 -1
- package/dist/getConfig.js +14 -20
- package/dist/getCurrentTest.d.ts +1 -1
- package/dist/getCurrentTest.js +15 -21
- package/dist/index.d.ts +13 -13
- package/dist/index.js +14 -38
- package/dist/logError.js +3 -6
- package/dist/logSection.js +5 -11
- package/dist/logTestStatus.js +19 -25
- package/dist/page.js +3 -6
- package/dist/parallel-ci.js +8 -14
- package/dist/run.js +42 -45
- package/dist/runAll.d.ts +1 -1
- package/dist/runAll.js +61 -67
- package/dist/runCommandThatTerminates.js +6 -9
- package/dist/skip.js +3 -6
- package/dist/test.js +5 -8
- package/dist/testScreenshotFixture.js +42 -45
- package/dist/utils/assert.js +23 -26
- package/dist/utils/cliOptions.js +9 -12
- package/dist/utils/findFiles.d.ts +1 -1
- package/dist/utils/findFiles.js +13 -19
- package/dist/utils/fsWindowsBugWorkaround.js +2 -5
- package/dist/utils/genPromise.js +1 -5
- package/dist/utils/hasProp.d.ts +15 -0
- package/dist/utils/hasProp.js +50 -0
- package/dist/utils/humanizeTime.js +1 -4
- package/dist/utils/isArray.d.ts +1 -0
- package/dist/utils/isArray.js +4 -0
- package/dist/utils/isArrayOfStrings.d.ts +2 -0
- package/dist/utils/isArrayOfStrings.js +5 -0
- package/dist/utils/isCallable.js +1 -5
- package/dist/utils/isMinNodeVersion.js +4 -7
- package/dist/utils/isObject.d.ts +1 -1
- package/dist/utils/isObject.js +1 -5
- package/dist/utils/isObjectOfStrings.d.ts +2 -0
- package/dist/utils/isObjectOfStrings.js +5 -0
- package/dist/utils/isTTY.js +1 -4
- package/dist/utils/logProgress.js +4 -7
- package/dist/utils/parseCli.js +3 -6
- package/dist/utils/platform.js +6 -9
- package/dist/utils/projectInfo.js +1 -4
- package/dist/utils/runCommand.js +7 -10
- package/dist/utils/runCommandLongRunning.js +40 -32
- package/dist/utils/runCommandShortLived.js +7 -10
- package/dist/utils/sleep.js +1 -4
- package/dist/utils/trackLogs.d.ts +1 -1
- package/dist/utils/trackLogs.js +1 -1
- package/dist/utils.d.ts +16 -0
- package/dist/utils.js +16 -0
- package/package.json +3 -2
- package/dist/utils/index.d.ts +0 -15
- package/dist/utils/index.js +0 -31
package/bin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import './dist/cli.js'
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isTolerateError = void 0;
|
|
7
|
-
const getConfig_1 = require("../getConfig");
|
|
8
|
-
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
1
|
+
export { isTolerateError };
|
|
2
|
+
import { getConfig } from '../getConfig.js';
|
|
3
|
+
import stripAnsi from 'strip-ansi';
|
|
9
4
|
function isTolerateError({ logSource, logText }) {
|
|
10
|
-
logText = (
|
|
5
|
+
logText = stripAnsi(logText);
|
|
11
6
|
if (tolerateErrorBuiltIn({ logSource, logText })) {
|
|
12
7
|
return true;
|
|
13
8
|
}
|
|
14
|
-
const config =
|
|
9
|
+
const config = getConfig();
|
|
15
10
|
if (config.tolerateError?.({ logSource, logText })) {
|
|
16
11
|
return true;
|
|
17
12
|
}
|
|
18
13
|
return false;
|
|
19
14
|
}
|
|
20
|
-
exports.isTolerateError = isTolerateError;
|
|
21
15
|
function tolerateErrorBuiltIn({ logSource, logText }) {
|
|
22
16
|
return [
|
|
23
17
|
{
|
package/dist/Logs.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export declare const Logs: {
|
|
|
8
8
|
logEagerly: false | "all" | "logs";
|
|
9
9
|
};
|
|
10
10
|
export type { LogSource };
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
type LogSource = 'stdout' | 'stderr' | 'Browser Error' | 'Browser Warning' | 'Browser Log' | 'Playwright' | 'run()' | 'run() failure' | 'test()' | 'Connection Error';
|
|
12
|
+
type LogEntry = {
|
|
13
13
|
logSource: LogSource;
|
|
14
14
|
logText: string;
|
|
15
15
|
logTimestamp: string;
|
package/dist/Logs.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Logs = exports.expectLog = void 0;
|
|
7
|
-
exports.Logs = {
|
|
1
|
+
export { expectLog };
|
|
2
|
+
export const Logs = {
|
|
8
3
|
add,
|
|
9
4
|
flushLogs,
|
|
10
5
|
logErrorsAndWarnings,
|
|
@@ -12,12 +7,12 @@ exports.Logs = {
|
|
|
12
7
|
hasFailLogs,
|
|
13
8
|
logEagerly: false,
|
|
14
9
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
import { assert, ensureNewTerminalLine, isWindows } from './utils.js';
|
|
11
|
+
import pc from '@brillout/picocolors';
|
|
12
|
+
import { getCurrentTestOptional } from './getCurrentTest.js';
|
|
13
|
+
import { logSection } from './logSection.js';
|
|
14
|
+
import { isTolerateError } from './Logs/isTolerateError.js';
|
|
15
|
+
import stripAnsi from 'strip-ansi';
|
|
21
16
|
let logEntries = [];
|
|
22
17
|
function hasFailLogs(failOnWarning) {
|
|
23
18
|
const failLogs = getErrorLogs(failOnWarning);
|
|
@@ -30,7 +25,7 @@ function getErrorLogs(includeWarnings) {
|
|
|
30
25
|
}
|
|
31
26
|
const { logSource } = logEntry;
|
|
32
27
|
// taskkill makes process exit with exit code `1` which makes npm emit logs on stderr
|
|
33
|
-
if (logEntry.loggedAfterExit &&
|
|
28
|
+
if (logEntry.loggedAfterExit && isWindows() && logSource === 'stderr') {
|
|
34
29
|
return false;
|
|
35
30
|
}
|
|
36
31
|
if (logSource === 'run() failure') {
|
|
@@ -53,11 +48,11 @@ function logErrorsAndWarnings() {
|
|
|
53
48
|
const errorAndWarningLogs = getErrorLogs(true);
|
|
54
49
|
if (errorAndWarningLogs.length === 0)
|
|
55
50
|
return;
|
|
56
|
-
|
|
51
|
+
logSection('ERROR & WARNING LOGS');
|
|
57
52
|
errorAndWarningLogs.forEach((logEntry) => printLog(logEntry));
|
|
58
53
|
}
|
|
59
54
|
function flushLogs() {
|
|
60
|
-
|
|
55
|
+
logSection('ALL LOGS');
|
|
61
56
|
logEntries.filter((logEntry) => !logEntry.loggedAfterExit).forEach((logEntry) => printLog(logEntry));
|
|
62
57
|
logEntries = [];
|
|
63
58
|
}
|
|
@@ -67,15 +62,15 @@ function add({ logSource, logText, loggedAfterExit = false, }) {
|
|
|
67
62
|
logSource,
|
|
68
63
|
logText,
|
|
69
64
|
logTimestamp,
|
|
70
|
-
isNotFailure:
|
|
65
|
+
isNotFailure: isTolerateError({ logSource, logText }),
|
|
71
66
|
loggedAfterExit,
|
|
72
67
|
};
|
|
73
68
|
logEntries.push(logEntry);
|
|
74
|
-
if (
|
|
69
|
+
if (Logs.logEagerly) {
|
|
75
70
|
let shouldLog = false;
|
|
76
|
-
if (
|
|
71
|
+
if (Logs.logEagerly === 'all')
|
|
77
72
|
shouldLog = true;
|
|
78
|
-
if (
|
|
73
|
+
if (Logs.logEagerly === 'logs' && logSource !== 'Playwright')
|
|
79
74
|
shouldLog = true;
|
|
80
75
|
if (shouldLog)
|
|
81
76
|
printLog(logEntry);
|
|
@@ -99,11 +94,10 @@ function expectLog(logText, logFilter) {
|
|
|
99
94
|
throw new Error(`The following log was logged as expected, but it didn't match the logFilter() you provided: "${logText}"`);
|
|
100
95
|
}
|
|
101
96
|
}
|
|
102
|
-
exports.expectLog = expectLog;
|
|
103
97
|
function removeAnsi(logEntry) {
|
|
104
98
|
const logEntryWithoutAnsi = {
|
|
105
99
|
...logEntry,
|
|
106
|
-
logText: (
|
|
100
|
+
logText: stripAnsi(logEntry.logText),
|
|
107
101
|
};
|
|
108
102
|
return logEntryWithoutAnsi;
|
|
109
103
|
}
|
|
@@ -117,9 +111,9 @@ function getTimestamp() {
|
|
|
117
111
|
function printLog(logEntry) {
|
|
118
112
|
const { logSource, logText, logTimestamp } = logEntry;
|
|
119
113
|
let logSourceLabel = colorize(logSource);
|
|
120
|
-
const testInfo =
|
|
114
|
+
const testInfo = getCurrentTestOptional();
|
|
121
115
|
// See https://github.com/nodejs/node/issues/8033#issuecomment-388323687
|
|
122
|
-
if (!
|
|
116
|
+
if (!ensureNewTerminalLine()) {
|
|
123
117
|
console.log('');
|
|
124
118
|
}
|
|
125
119
|
let msg = logText;
|
|
@@ -130,30 +124,30 @@ function printLog(logEntry) {
|
|
|
130
124
|
msg = msg.trim();
|
|
131
125
|
let testInfoLabels = '';
|
|
132
126
|
if (testInfo) {
|
|
133
|
-
|
|
127
|
+
assert(testInfo.runInfo, testInfo);
|
|
134
128
|
testInfoLabels = `[${testInfo.testName}][${testInfo.runInfo.cmd}]`;
|
|
135
129
|
}
|
|
136
130
|
console.log(`[${logTimestamp}]${testInfoLabels}[${logSourceLabel}] ${msg}`);
|
|
137
131
|
}
|
|
138
132
|
function colorize(logSource) {
|
|
139
|
-
const { bold } =
|
|
133
|
+
const { bold } = pc;
|
|
140
134
|
if (logSource === 'stderr' ||
|
|
141
135
|
logSource === 'Browser Error' ||
|
|
142
136
|
logSource === 'Connection Error' ||
|
|
143
137
|
logSource === 'run() failure') {
|
|
144
|
-
return bold(
|
|
138
|
+
return bold(pc.red(logSource));
|
|
145
139
|
}
|
|
146
140
|
if (logSource === 'Browser Warning') {
|
|
147
|
-
return bold(
|
|
141
|
+
return bold(pc.yellow(logSource));
|
|
148
142
|
}
|
|
149
143
|
if (logSource === 'stdout' || logSource === 'Browser Log') {
|
|
150
|
-
return bold(
|
|
144
|
+
return bold(pc.blue(logSource));
|
|
151
145
|
}
|
|
152
146
|
if (logSource === 'Playwright') {
|
|
153
|
-
return bold(
|
|
147
|
+
return bold(pc.magenta(logSource));
|
|
154
148
|
}
|
|
155
149
|
if (logSource === 'run()' || logSource === 'test()') {
|
|
156
|
-
return bold(
|
|
150
|
+
return bold(pc.cyan(logSource));
|
|
157
151
|
}
|
|
158
|
-
|
|
152
|
+
assert(false);
|
|
159
153
|
}
|
package/dist/TIMEOUTS.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.TIMEOUT_PROCESS_TERMINATION = 10 * 1000 * (!(0, platform_1.isCI)() ? 1 : (0, platform_1.isWindows)() ? 3 : !(0, platform_1.isLinux)() ? 3 : 1);
|
|
8
|
-
exports.TIMEOUT_AUTORETRY = exports.TIMEOUT_TEST_FUNCTION / 2;
|
|
9
|
-
exports.TIMEOUT_PLAYWRIGHT = exports.TIMEOUT_TEST_FUNCTION / 2;
|
|
1
|
+
import { isWindows, isLinux, isCI } from './utils/platform.js';
|
|
2
|
+
export const TIMEOUT_NPM_SCRIPT = 2 * 60 * 1000 * (!isCI() ? 1 : isWindows() ? 2 : 1);
|
|
3
|
+
export const TIMEOUT_TEST_FUNCTION = 60 * 1000 * (!isCI() ? 1 : isWindows() ? 5 : 3);
|
|
4
|
+
export const TIMEOUT_PROCESS_TERMINATION = 10 * 1000 * (!isCI() ? 1 : isWindows() ? 3 : !isLinux() ? 3 : 1);
|
|
5
|
+
export const TIMEOUT_AUTORETRY = TIMEOUT_TEST_FUNCTION / 2;
|
|
6
|
+
export const TIMEOUT_PLAYWRIGHT = TIMEOUT_TEST_FUNCTION / 2;
|
package/dist/autoRetry.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const utils_1 = require("./utils");
|
|
6
|
-
async function autoRetry(test, { timeout = TIMEOUTS_1.TIMEOUT_AUTORETRY } = {}) {
|
|
1
|
+
export { autoRetry };
|
|
2
|
+
import { TIMEOUT_AUTORETRY } from './TIMEOUTS.js';
|
|
3
|
+
import { sleep } from './utils.js';
|
|
4
|
+
async function autoRetry(test, { timeout = TIMEOUT_AUTORETRY } = {}) {
|
|
7
5
|
const period = 100;
|
|
8
6
|
const numberOfTries = timeout / period;
|
|
9
7
|
let i = 0;
|
|
@@ -18,7 +16,6 @@ async function autoRetry(test, { timeout = TIMEOUTS_1.TIMEOUT_AUTORETRY } = {})
|
|
|
18
16
|
throw err;
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
|
-
await
|
|
19
|
+
await sleep(period);
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
|
-
exports.autoRetry = autoRetry;
|
package/dist/buildTs.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.sourceMaps = exports.buildTs = void 0;
|
|
7
|
-
const esbuild_1 = __importDefault(require("esbuild"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const utils_1 = require("./utils");
|
|
1
|
+
export { buildTs };
|
|
2
|
+
export { sourceMaps };
|
|
3
|
+
import esbuild from 'esbuild';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import { cliOptions } from './utils.js';
|
|
10
6
|
const sourceMaps = {};
|
|
11
|
-
exports.sourceMaps = sourceMaps;
|
|
12
7
|
async function buildTs(entry, outfile) {
|
|
13
|
-
await
|
|
8
|
+
await esbuild.build({
|
|
14
9
|
platform: 'node',
|
|
15
10
|
entryPoints: [entry],
|
|
16
11
|
sourcemap: true,
|
|
@@ -24,15 +19,14 @@ async function buildTs(entry, outfile) {
|
|
|
24
19
|
});
|
|
25
20
|
{
|
|
26
21
|
const sourceMapFile = `${outfile}.map`;
|
|
27
|
-
sourceMaps[outfile] =
|
|
28
|
-
|
|
22
|
+
sourceMaps[outfile] = fs.readFileSync(sourceMapFile, 'utf8');
|
|
23
|
+
fs.unlinkSync(sourceMapFile);
|
|
29
24
|
}
|
|
30
25
|
const clean = () => {
|
|
31
|
-
if (
|
|
26
|
+
if (cliOptions.debugEsbuild) {
|
|
32
27
|
return;
|
|
33
28
|
}
|
|
34
|
-
|
|
29
|
+
fs.unlinkSync(`${outfile}`);
|
|
35
30
|
};
|
|
36
31
|
return clean;
|
|
37
32
|
}
|
|
38
|
-
exports.buildTs = buildTs;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ChaiPlugin } from './types';
|
|
1
|
+
import type { ChaiPlugin } from './types.js';
|
|
2
2
|
export declare const JestChaiExpect: ChaiPlugin;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JestChaiExpect = void 0;
|
|
4
1
|
// Copied from https://github.com/vitest-dev/vitest/blob/f3524602ccc678badaae6bc5c3945008d8cfd82a/packages/vitest/src/integrations/chai/jest-expect.ts
|
|
5
|
-
const JestChaiExpect = (chai, utils) => {
|
|
2
|
+
export const JestChaiExpect = (chai, utils) => {
|
|
6
3
|
function def(name, fn) {
|
|
7
4
|
utils.addMethod(chai.Assertion.prototype, name, fn);
|
|
8
5
|
}
|
|
@@ -24,4 +21,3 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
24
21
|
this.assert(!obj, 'expected #{this} to be falsy', 'expected #{this} to not be falsy', obj);
|
|
25
22
|
});
|
|
26
23
|
};
|
|
27
|
-
exports.JestChaiExpect = JestChaiExpect;
|
package/dist/chai/expect.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Expect } from './types';
|
|
1
|
+
import type { Expect } from './types.js';
|
|
2
2
|
export declare const expect: Expect;
|
package/dist/chai/expect.js
CHANGED
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.expect = void 0;
|
|
27
|
-
const JestChaiExpect_1 = require("./JestChaiExpect");
|
|
28
|
-
const chai = __importStar(require("chai"));
|
|
29
|
-
chai.use(JestChaiExpect_1.JestChaiExpect);
|
|
30
|
-
exports.expect = chai.expect;
|
|
1
|
+
import { JestChaiExpect } from './JestChaiExpect.js';
|
|
2
|
+
import * as chai from 'chai';
|
|
3
|
+
chai.use(JestChaiExpect);
|
|
4
|
+
export const expect = chai.expect;
|
package/dist/chai/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export type { ChaiPlugin };
|
|
2
2
|
export type { Expect };
|
|
3
3
|
import type { use as chaiUse } from 'chai';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
type FirstFunctionArgument<T> = T extends (arg: infer A) => unknown ? A : never;
|
|
5
|
+
type ChaiPlugin = FirstFunctionArgument<typeof chaiUse>;
|
|
6
|
+
type Assertion = Chai.Assertion & {
|
|
7
7
|
not: Assertion;
|
|
8
8
|
toContain: Assertion['contain'];
|
|
9
9
|
toMatch: Assertion['match'];
|
|
@@ -12,4 +12,4 @@ declare type Assertion = Chai.Assertion & {
|
|
|
12
12
|
toBeTruthy(): void;
|
|
13
13
|
toBee: Assertion['equal'];
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
type Expect = (value: any) => Assertion;
|
package/dist/chai/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/cli.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* Track down log origins
|
|
3
2
|
import './utils/trackLogs'
|
|
4
3
|
//*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
const runAll_1 = require("./runAll");
|
|
12
|
-
const buildTs_1 = require("./buildTs");
|
|
13
|
-
const Logs_1 = require("./Logs");
|
|
4
|
+
import sourceMapSupport from 'source-map-support';
|
|
5
|
+
import { assert, findFilesParseCliArgs, fsWindowsBugWorkaroundPrefix } from './utils.js';
|
|
6
|
+
import { runAll } from './runAll.js';
|
|
7
|
+
import { sourceMaps } from './buildTs.js';
|
|
8
|
+
import { Logs } from './Logs.js';
|
|
14
9
|
initSourceMap();
|
|
15
10
|
initPromiseRejectionHandler();
|
|
16
11
|
initUserExitHandler();
|
|
17
12
|
cli();
|
|
18
13
|
function cli() {
|
|
19
|
-
const filter =
|
|
20
|
-
|
|
14
|
+
const filter = findFilesParseCliArgs();
|
|
15
|
+
runAll(filter);
|
|
21
16
|
}
|
|
22
17
|
function initPromiseRejectionHandler() {
|
|
23
18
|
process.on('unhandledRejection', function (err) {
|
|
@@ -27,31 +22,31 @@ function initPromiseRejectionHandler() {
|
|
|
27
22
|
}
|
|
28
23
|
function initUserExitHandler() {
|
|
29
24
|
process.on('SIGINT', function () {
|
|
30
|
-
|
|
25
|
+
Logs.flushLogs();
|
|
31
26
|
});
|
|
32
27
|
}
|
|
33
28
|
// This mechanism seems necessary for the source map to apply for errors that happen a long time after the build file, which contains the inline source map, is removed.
|
|
34
29
|
// - The much simpler alternative used by Vike doesn't seem to work: https://github.com/brillout/vite-plugin-ssr/blob/77b1b0e8b6c1ed4efe3e3039f7c0b23a00651663/vite-plugin-ssr/node/plugin/plugins/importUserCode/v1-design/transpileAndLoadFile.ts#L200-L208
|
|
35
30
|
// - Failed attempt to make the simpler alternative work: https://github.com/brillout/test-e2e/commit/681abd19459b8c7d3ade9363ba32be86e3fdcb53
|
|
36
31
|
function initSourceMap() {
|
|
37
|
-
|
|
32
|
+
sourceMapSupport.install({
|
|
38
33
|
retrieveSourceMap: function (source) {
|
|
39
|
-
const prefix =
|
|
34
|
+
const prefix = fsWindowsBugWorkaroundPrefix;
|
|
40
35
|
if (source.startsWith(prefix)) {
|
|
41
36
|
source = source.slice(prefix.length);
|
|
42
37
|
if (process.platform == 'win32') {
|
|
43
|
-
|
|
38
|
+
assert(source.startsWith('/'));
|
|
44
39
|
source = source.slice(1);
|
|
45
40
|
source = source.split('/').join('\\');
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
|
-
let sourceMap =
|
|
43
|
+
let sourceMap = sourceMaps[source];
|
|
49
44
|
if (sourceMap) {
|
|
50
45
|
return {
|
|
51
46
|
map: sourceMap,
|
|
52
47
|
};
|
|
53
48
|
}
|
|
54
|
-
|
|
49
|
+
assert(!source.endsWith('.test.mjs'), { source, sourceMapsKeys: Object.keys(sourceMaps) });
|
|
55
50
|
return null;
|
|
56
51
|
},
|
|
57
52
|
});
|
package/dist/editFile.js
CHANGED
|
@@ -1,49 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const getCurrentTest_1 = require("./getCurrentTest");
|
|
1
|
+
export { editFile };
|
|
2
|
+
export { editFileRevert };
|
|
3
|
+
export { editFileAssertReverted };
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { assert } from './utils.js';
|
|
7
|
+
import { getCurrentTest } from './getCurrentTest.js';
|
|
8
|
+
import { createRequire } from 'module';
|
|
9
|
+
const require_ = createRequire(import.meta.url);
|
|
11
10
|
const filesContentOriginal = {};
|
|
12
11
|
function editFile(filePathRelative, replacer) {
|
|
13
12
|
const filePath = getFilePath(filePathRelative);
|
|
14
|
-
const fileContent =
|
|
13
|
+
const fileContent = fs.readFileSync(filePath, 'utf8');
|
|
15
14
|
if (!(filePath in filesContentOriginal)) {
|
|
16
15
|
filesContentOriginal[filePath] = fileContent;
|
|
17
16
|
}
|
|
18
17
|
const fileContentNew = replacer(fileContent);
|
|
19
18
|
// expect(fileContentNew).not.toBe(fileContent)
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
assert(fileContentNew !== fileContent);
|
|
20
|
+
fs.writeFileSync(filePath, fileContentNew);
|
|
22
21
|
}
|
|
23
|
-
exports.editFile = editFile;
|
|
24
22
|
function editFileRevert() {
|
|
25
23
|
Object.entries(filesContentOriginal).forEach(([filePath, fileContent]) => {
|
|
26
|
-
|
|
24
|
+
fs.writeFileSync(filePath, fileContent);
|
|
27
25
|
delete filesContentOriginal[filePath];
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
|
-
exports.editFileRevert = editFileRevert;
|
|
31
28
|
function editFileAssertReverted() {
|
|
32
29
|
const filesDirty = Object.keys(filesContentOriginal);
|
|
33
30
|
try {
|
|
34
31
|
// expect(filesDirty).toEqual([])
|
|
35
|
-
|
|
32
|
+
assert(filesDirty.length === 0);
|
|
36
33
|
}
|
|
37
34
|
catch (err) {
|
|
38
35
|
editFileRevert();
|
|
39
36
|
throw err;
|
|
40
37
|
}
|
|
41
|
-
|
|
38
|
+
assert(filesDirty.length === 0);
|
|
42
39
|
}
|
|
43
|
-
exports.editFileAssertReverted = editFileAssertReverted;
|
|
44
40
|
function getFilePath(filePathRelative) {
|
|
45
|
-
const { testFile } =
|
|
46
|
-
const cwd =
|
|
47
|
-
const filePath =
|
|
41
|
+
const { testFile } = getCurrentTest();
|
|
42
|
+
const cwd = path.dirname(testFile);
|
|
43
|
+
const filePath = require_.resolve(filePathRelative, { paths: [cwd] });
|
|
48
44
|
return filePath;
|
|
49
45
|
}
|
package/dist/fetch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { fetch };
|
|
2
2
|
export { fetchHtml };
|
|
3
|
-
import
|
|
3
|
+
import type { RequestInfo, RequestInit, Response } from 'node-fetch';
|
|
4
4
|
declare function fetchHtml(pathname: string): Promise<string>;
|
|
5
|
-
declare function fetch(
|
|
5
|
+
declare function fetch(url: RequestInfo, init?: RequestInit): Promise<Response>;
|
package/dist/fetch.js
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.fetchHtml = exports.fetch = void 0;
|
|
7
|
-
const getCurrentTest_1 = require("./getCurrentTest");
|
|
8
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
9
|
-
const Logs_1 = require("./Logs");
|
|
1
|
+
export { fetch };
|
|
2
|
+
export { fetchHtml };
|
|
3
|
+
import { getServerUrl } from './getCurrentTest.js';
|
|
4
|
+
import fetch_ from 'node-fetch';
|
|
5
|
+
import { Logs } from './Logs.js';
|
|
10
6
|
async function fetchHtml(pathname) {
|
|
11
|
-
const response = await fetch(
|
|
7
|
+
const response = await fetch(getServerUrl() + pathname);
|
|
12
8
|
const html = await response.text();
|
|
13
9
|
return html;
|
|
14
10
|
}
|
|
15
|
-
|
|
16
|
-
async function fetch(...args) {
|
|
11
|
+
async function fetch(url, init) {
|
|
17
12
|
try {
|
|
18
|
-
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
//
|
|
15
|
+
// I don't know why but [transition to ESM](https://github.com/brillout/test-e2e/commit/9b0822a4f5bf787de5a150173f3eeffcfa7ebc5c) broke the default importing of the node-fetch types.
|
|
16
|
+
//
|
|
17
|
+
// The following used to work but doens't anymore:
|
|
18
|
+
// ```js
|
|
19
|
+
// async function fetch(...args: Parameters<typeof fetch_>) {
|
|
20
|
+
// // ...
|
|
21
|
+
// }
|
|
22
|
+
// ```
|
|
23
|
+
return await fetch_(url, init);
|
|
19
24
|
}
|
|
20
25
|
catch (err) {
|
|
21
|
-
|
|
26
|
+
Logs.add({
|
|
22
27
|
logSource: 'Connection Error',
|
|
23
|
-
logText: `Couldn't connect to \`${
|
|
28
|
+
logText: `Couldn't connect to \`${url}\`. Args: \`${JSON.stringify(init)}\`. Err: \`${
|
|
24
29
|
// @ts-ignore
|
|
25
30
|
err.message}\``,
|
|
26
31
|
});
|
|
27
32
|
throw new Error("Couldn't connect to server. See `Connection Error` log for more details.");
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
|
-
exports.fetch = fetch;
|
package/dist/findTestFiles.d.ts
CHANGED
package/dist/findTestFiles.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const utils_1 = require("./utils");
|
|
5
|
-
const parallel_ci_1 = require("./parallel-ci");
|
|
1
|
+
export { findTestFiles };
|
|
2
|
+
import { filterFiles, findFiles } from './utils.js';
|
|
3
|
+
import { getTestFilesForCurrentJob } from './parallel-ci.js';
|
|
6
4
|
// Unit tests `**/*.spec.*` are handled by Vitest
|
|
7
5
|
const testFilenamePattern = '**/*.test.ts';
|
|
8
6
|
async function findTestFiles(findFilter) {
|
|
9
7
|
const testFilesAll = await findTestFilesAll();
|
|
10
|
-
const testFiles =
|
|
8
|
+
const testFiles = filterFiles(testFilesAll, findFilter);
|
|
11
9
|
return testFiles;
|
|
12
10
|
}
|
|
13
|
-
exports.findTestFiles = findTestFiles;
|
|
14
11
|
async function findTestFilesAll() {
|
|
15
12
|
{
|
|
16
|
-
const testFiles =
|
|
13
|
+
const testFiles = getTestFilesForCurrentJob();
|
|
17
14
|
if (testFiles)
|
|
18
15
|
return testFiles;
|
|
19
16
|
}
|
|
20
17
|
{
|
|
21
|
-
const testFiles =
|
|
18
|
+
const testFiles = findFiles(testFilenamePattern);
|
|
22
19
|
return testFiles;
|
|
23
20
|
}
|
|
24
21
|
}
|
package/dist/getBrowser.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const Logs_1 = require("./Logs");
|
|
6
|
-
const utils_1 = require("./utils");
|
|
1
|
+
export { getBrowser };
|
|
2
|
+
import { chromium } from 'playwright-chromium';
|
|
3
|
+
import { Logs } from './Logs.js';
|
|
4
|
+
import { assert, logProgress } from './utils.js';
|
|
7
5
|
let browser;
|
|
8
6
|
async function getBrowser() {
|
|
9
7
|
if (!browser) {
|
|
10
|
-
const done =
|
|
11
|
-
browser = await
|
|
8
|
+
const done = logProgress('Launch Browser');
|
|
9
|
+
browser = await chromium.launch({
|
|
12
10
|
headless: true,
|
|
13
11
|
logger: {
|
|
14
12
|
isEnabled: () => true,
|
|
15
13
|
log: (name, _severity, message, args, _hint, ...rest) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
assert(args.length === 0);
|
|
15
|
+
assert(rest.length === 0);
|
|
16
|
+
Logs.add({
|
|
19
17
|
logSource: 'Playwright',
|
|
20
18
|
logText: `${name} ${message}`,
|
|
21
19
|
});
|
|
@@ -26,4 +24,3 @@ async function getBrowser() {
|
|
|
26
24
|
}
|
|
27
25
|
return browser;
|
|
28
26
|
}
|
|
29
|
-
exports.getBrowser = getBrowser;
|