@brillout/test-e2e 0.5.24 → 0.5.25
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/buildTs.d.ts +2 -0
- package/dist/buildTs.js +11 -4
- package/dist/cli.js +32 -0
- package/dist/runAll.d.ts +0 -1
- package/dist/runAll.js +2 -15
- package/dist/utils/fsWindowsBugWorkaround.d.ts +2 -0
- package/dist/utils/fsWindowsBugWorkaround.js +2 -1
- package/package.json +1 -1
package/dist/buildTs.d.ts
CHANGED
package/dist/buildTs.js
CHANGED
|
@@ -3,15 +3,17 @@ 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.buildTs = void 0;
|
|
6
|
+
exports.sourceMaps = exports.buildTs = void 0;
|
|
7
7
|
const esbuild_1 = __importDefault(require("esbuild"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const utils_1 = require("./utils");
|
|
10
|
+
const sourceMaps = {};
|
|
11
|
+
exports.sourceMaps = sourceMaps;
|
|
10
12
|
async function buildTs(entry, outfile) {
|
|
11
13
|
await esbuild_1.default.build({
|
|
12
14
|
platform: 'node',
|
|
13
15
|
entryPoints: [entry],
|
|
14
|
-
sourcemap:
|
|
16
|
+
sourcemap: true,
|
|
15
17
|
outfile,
|
|
16
18
|
logLevel: 'warning',
|
|
17
19
|
format: 'esm',
|
|
@@ -20,12 +22,17 @@ async function buildTs(entry, outfile) {
|
|
|
20
22
|
packages: 'external',
|
|
21
23
|
minify: false,
|
|
22
24
|
});
|
|
23
|
-
|
|
25
|
+
{
|
|
26
|
+
const sourceMapFile = `${outfile}.map`;
|
|
27
|
+
sourceMaps[outfile] = fs_1.default.readFileSync(sourceMapFile, 'utf8');
|
|
28
|
+
fs_1.default.unlinkSync(sourceMapFile);
|
|
29
|
+
}
|
|
30
|
+
const clean = () => {
|
|
24
31
|
if (utils_1.cliOptions.debugEsbuild) {
|
|
25
32
|
return;
|
|
26
33
|
}
|
|
27
34
|
fs_1.default.unlinkSync(`${outfile}`);
|
|
28
35
|
};
|
|
29
|
-
return
|
|
36
|
+
return clean;
|
|
30
37
|
}
|
|
31
38
|
exports.buildTs = buildTs;
|
package/dist/cli.js
CHANGED
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
/* Track down log origins
|
|
3
3
|
import './utils/trackLogs'
|
|
4
4
|
//*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
5
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const source_map_support_1 = __importDefault(require("source-map-support"));
|
|
6
10
|
const utils_1 = require("./utils");
|
|
7
11
|
const runAll_1 = require("./runAll");
|
|
12
|
+
const buildTs_1 = require("./buildTs");
|
|
8
13
|
const Logs_1 = require("./Logs");
|
|
14
|
+
initSourceMap();
|
|
9
15
|
initPromiseRejectionHandler();
|
|
10
16
|
initUserExitHandler();
|
|
11
17
|
cli();
|
|
@@ -24,3 +30,29 @@ function initUserExitHandler() {
|
|
|
24
30
|
Logs_1.Logs.flushLogs();
|
|
25
31
|
});
|
|
26
32
|
}
|
|
33
|
+
// 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
|
+
// - 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
|
+
// - Failed attempt to make the simpler alternative work: https://github.com/brillout/test-e2e/commit/681abd19459b8c7d3ade9363ba32be86e3fdcb53
|
|
36
|
+
function initSourceMap() {
|
|
37
|
+
source_map_support_1.default.install({
|
|
38
|
+
retrieveSourceMap: function (source) {
|
|
39
|
+
const prefix = utils_1.fsWindowsBugWorkaroundPrefix;
|
|
40
|
+
if (source.startsWith(prefix)) {
|
|
41
|
+
source = source.slice(prefix.length);
|
|
42
|
+
if (process.platform == 'win32') {
|
|
43
|
+
(0, utils_1.assert)(source.startsWith('/'));
|
|
44
|
+
source = source.slice(1);
|
|
45
|
+
source = source.split('/').join('\\');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
let sourceMap = buildTs_1.sourceMaps[source];
|
|
49
|
+
if (sourceMap) {
|
|
50
|
+
return {
|
|
51
|
+
map: sourceMap,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
(0, utils_1.assert)(!source.endsWith('.test.mjs'), { source, sourceMapsKeys: Object.keys(buildTs_1.sourceMaps) });
|
|
55
|
+
return null;
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
package/dist/runAll.d.ts
CHANGED
package/dist/runAll.js
CHANGED
|
@@ -16,7 +16,6 @@ const getConfig_1 = require("./getConfig");
|
|
|
16
16
|
const logError_1 = require("./logError");
|
|
17
17
|
const logTestStatus_1 = require("./logTestStatus");
|
|
18
18
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
19
|
-
require("source-map-support/register.js");
|
|
20
19
|
async function runAll(filter) {
|
|
21
20
|
await (0, getConfig_1.loadConfig)();
|
|
22
21
|
const testFiles = await (0, findTestFiles_1.findTestFiles)(filter);
|
|
@@ -78,7 +77,7 @@ async function buildAndTest(testFile, browser, isThirdAttempt) {
|
|
|
78
77
|
const cacheBuster = Date.now();
|
|
79
78
|
const testFileJs = testFile.replace('.ts', `.${cacheBuster}.mjs`);
|
|
80
79
|
(0, utils_1.assert)(testFileJs.endsWith('.mjs'));
|
|
81
|
-
const
|
|
80
|
+
const cleanBuild = await (0, buildTs_1.buildTs)(testFile, testFileJs);
|
|
82
81
|
(0, getCurrentTest_2.setCurrentTest)(testFile);
|
|
83
82
|
(0, logTestStatus_1.logBoot)();
|
|
84
83
|
let execErr;
|
|
@@ -86,13 +85,11 @@ async function buildAndTest(testFile, browser, isThirdAttempt) {
|
|
|
86
85
|
await import((0, utils_2.fsWindowsBugWorkaround)(testFileJs));
|
|
87
86
|
}
|
|
88
87
|
catch (err) {
|
|
89
|
-
// Ensure the source map is loaded before we remove testFileJs contains the inline source map
|
|
90
|
-
installSourceMap(err);
|
|
91
88
|
(0, utils_1.assert)(err);
|
|
92
89
|
execErr = err;
|
|
93
90
|
}
|
|
94
91
|
finally {
|
|
95
|
-
|
|
92
|
+
cleanBuild();
|
|
96
93
|
}
|
|
97
94
|
if (execErr) {
|
|
98
95
|
(0, logTestStatus_1.logFail)(`an error was thrown while executing the file ${testFile}`, true);
|
|
@@ -256,13 +253,3 @@ function assertSkipUsage(testInfo) {
|
|
|
256
253
|
(0, utils_1.assertUsage)(testInfo.tests === undefined, err);
|
|
257
254
|
}
|
|
258
255
|
}
|
|
259
|
-
// This tiggers Error.prepareStackTrace() which is needed for the npm package 'source-map-support': the Error.prepareStackTrace() hook of 'source-map-support' needs to be called before the file containing the source map is removed.
|
|
260
|
-
function installSourceMap(err) {
|
|
261
|
-
if ((0, utils_1.isObject)(err)) {
|
|
262
|
-
// Accessing err.stack triggers prepareStackTrace()
|
|
263
|
-
const { stack } = err;
|
|
264
|
-
// Ensure no compiler removes the line above
|
|
265
|
-
if (1 + 1 === 3)
|
|
266
|
-
console.log('I_AM_NEVER_SHOWN' + stack);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fsWindowsBugWorkaround = void 0;
|
|
3
|
+
exports.fsWindowsBugWorkaroundPrefix = exports.fsWindowsBugWorkaround = void 0;
|
|
4
4
|
const fsWindowsBugWorkaroundPrefix = 'file://';
|
|
5
|
+
exports.fsWindowsBugWorkaroundPrefix = fsWindowsBugWorkaroundPrefix;
|
|
5
6
|
// https://stackoverflow.com/questions/69665780/error-err-unsupported-esm-url-scheme-only-file-and-data-urls-are-supported-by/70057245#70057245
|
|
6
7
|
function fsWindowsBugWorkaround(testFileJs) {
|
|
7
8
|
return `${fsWindowsBugWorkaroundPrefix}${testFileJs}`;
|