@brillout/test-e2e 0.5.6 → 0.5.8

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/cli.js CHANGED
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ /* Track down log origins
3
+ import './utils/trackLogs'
4
+ //*/
2
5
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
6
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
7
  };
@@ -1,8 +1,10 @@
1
1
  export { logPass };
2
2
  export { logWarn };
3
3
  export { logFail };
4
+ export { logBoot };
4
5
  export { hasFail };
5
6
  declare function logPass(): void;
6
7
  declare function logWarn(warning: string): void;
7
8
  declare function logFail(reason: string, isFinalAttempt: boolean): void;
9
+ declare function logBoot(): void;
8
10
  declare function hasFail(): boolean;
@@ -3,7 +3,7 @@ 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.hasFail = exports.logFail = exports.logWarn = exports.logPass = void 0;
6
+ exports.hasFail = exports.logBoot = exports.logFail = exports.logWarn = exports.logPass = void 0;
7
7
  const getCurrentTest_1 = require("./getCurrentTest");
8
8
  const utils_1 = require("./utils");
9
9
  const picocolors_1 = __importDefault(require("picocolors"));
@@ -47,8 +47,15 @@ function getStatusTags() {
47
47
  const PASS = picocolors_1.default.bold(picocolors_1.default.white(picocolors_1.default.bgGreen(' PASS ')));
48
48
  const FAIL = picocolors_1.default.bold(picocolors_1.default.white(picocolors_1.default.bgRed(' FAIL ')));
49
49
  const WARN = picocolors_1.default.bold(picocolors_1.default.white(picocolors_1.default.bgYellow(' WARN ')));
50
- return { PASS, FAIL, WARN };
50
+ const BOOT = picocolors_1.default.bold(picocolors_1.default.white(picocolors_1.default.bgBlack(' BOOT ')));
51
+ return { PASS, FAIL, WARN, BOOT };
51
52
  }
53
+ function logBoot() {
54
+ const { testFile } = (0, getCurrentTest_1.getCurrentTest)();
55
+ const { BOOT } = getStatusTags();
56
+ console.log(`${BOOT} ${testFile}`);
57
+ }
58
+ exports.logBoot = logBoot;
52
59
  let hasFailLog = false;
53
60
  function hasFail() {
54
61
  return hasFailLog;
package/dist/runAll.js CHANGED
@@ -17,14 +17,19 @@ async function runAll(filter) {
17
17
  await (0, getConfig_1.loadConfig)();
18
18
  const testFiles = await (0, findTestFiles_1.findTestFiles)(filter);
19
19
  const browser = await (0, getBrowser_1.getBrowser)();
20
- const hasFailedTestFile = await runTestFiles(testFiles, browser);
20
+ const failedTestFiles = await runTestFiles(testFiles, browser);
21
21
  await browser.close();
22
+ const hasFailedTestFile = failedTestFiles.length > 0;
22
23
  const hasFailLog = (0, logTestStatus_1.hasFail)();
23
24
  if (hasFailedTestFile || hasFailLog) {
24
25
  // hasFailedTestFile and hasFailLog are redundant
25
26
  // - When assert.ts calls logFail() this code block isn't run
26
27
  (0, utils_1.assert)(hasFailedTestFile && hasFailLog);
27
- throw new Error('Following tests failed, see logs above for more information.');
28
+ (0, utils_1.assert)(failedTestFiles.length > 0);
29
+ throw new Error([
30
+ 'Following test files failed, see all the logs printed above for more information.',
31
+ ...failedTestFiles.map((testFile) => ` ${testFile}`),
32
+ ].join('\n'));
28
33
  }
29
34
  }
30
35
  exports.runAll = runAll;
@@ -37,7 +42,7 @@ async function runTestFiles(testFiles, browser) {
37
42
  }
38
43
  }
39
44
  if (!(0, utils_1.isCI)()) {
40
- return failedFirstAttempt.length > 0;
45
+ return failedFirstAttempt;
41
46
  }
42
47
  const failedSecondAttempt = [];
43
48
  for (const testFile of failedFirstAttempt) {
@@ -46,7 +51,7 @@ async function runTestFiles(testFiles, browser) {
46
51
  failedSecondAttempt.push(testFile);
47
52
  }
48
53
  }
49
- return failedSecondAttempt.length > 0;
54
+ return failedSecondAttempt;
50
55
  }
51
56
  async function buildAndTest(testFile, browser, isSecondAttempt) {
52
57
  (0, utils_1.assert)(testFile.endsWith('.ts'));
@@ -115,10 +120,6 @@ async function runServerAndTests(browser, isSecondAttempt) {
115
120
  return success;
116
121
  }
117
122
  async function runTests(testInfo, isFinalAttempt) {
118
- if (utils_1.isTTY) {
119
- console.log();
120
- console.log(testInfo.testFile);
121
- }
122
123
  // Set when user calls `run()`
123
124
  (0, utils_1.assert)(testInfo.runInfo);
124
125
  (0, utils_1.assert)(testInfo.afterEach);
@@ -129,7 +130,7 @@ async function runTests(testInfo, isFinalAttempt) {
129
130
  logSource: 'test()',
130
131
  logText: testDesc,
131
132
  });
132
- const done = (0, utils_1.logProgress)(`| [test] ${testDesc}`);
133
+ const done = (0, utils_1.logProgress)(`[test] ${testDesc}`);
133
134
  let err;
134
135
  try {
135
136
  await runTest(testFn, testInfo.runInfo.testFunctionTimeout);
package/dist/setup.js CHANGED
@@ -19,6 +19,7 @@ const strip_ansi_1 = __importDefault(require("strip-ansi"));
19
19
  const editFile_1 = require("./editFile");
20
20
  const getCurrentTest_1 = require("./getCurrentTest");
21
21
  const page_1 = require("./page");
22
+ const logTestStatus_1 = require("./logTestStatus");
22
23
  var part_regex_1 = require("@brillout/part-regex");
23
24
  Object.defineProperty(exports, "partRegex", { enumerable: true, get: function () { return part_regex_1.partRegex; } });
24
25
  var Logs_2 = require("./Logs");
@@ -132,7 +133,11 @@ function getRunInfo() {
132
133
  }
133
134
  async function start() {
134
135
  const { cmd, additionalTimeout, serverIsReadyMessage, serverIsReadyDelay } = getRunInfo();
135
- const done = (0, utils_1.logProgress)(`| [run] ${cmd}`);
136
+ if (utils_1.isTTY) {
137
+ console.log();
138
+ (0, logTestStatus_1.logBoot)();
139
+ }
140
+ const done = (0, utils_1.logProgress)(`[run] ${cmd}`);
136
141
  let hasSuccessfullyStarted = false;
137
142
  let resolveServerStart;
138
143
  let rejectServerStart;
@@ -0,0 +1 @@
1
+ declare function trackLogs(): void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ trackLogs();
3
+ // https://stackoverflow.com/questions/45395369/how-to-get-console-log-line-numbers-shown-in-nodejs/75109905#75109905
4
+ function trackLogs() {
5
+ const logOriginal = process.stdout.write;
6
+ // @ts-ignore
7
+ const log = (msg) => logOriginal.call(process.stdout, msg + '\n');
8
+ ['stdout', 'stderr'].forEach((stdName) => {
9
+ // @ts-ignore
10
+ var methodOriginal = process[stdName].write;
11
+ // @ts-ignore
12
+ process[stdName].write = function (...args) {
13
+ log('LOG:');
14
+ // @ts-ignore
15
+ methodOriginal.apply(process[stdName], args);
16
+ // @ts-ignore
17
+ log(new Error().stack.replace(/^Error/, 'LOGGED FROM:'));
18
+ };
19
+ });
20
+ Error.stackTraceLimit = Infinity;
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {