@brillout/test-e2e 0.5.19 → 0.5.20

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.
Files changed (2) hide show
  1. package/dist/runAll.js +20 -16
  2. package/package.json +1 -1
package/dist/runAll.js CHANGED
@@ -37,10 +37,10 @@ async function runTestFiles(testFiles, browser) {
37
37
  let failedTestFiles = [];
38
38
  let doNotRetry = false;
39
39
  for (const testFile of testFiles) {
40
- const success = await buildAndTest(testFile, browser, false);
40
+ const { success, isFlaky } = await buildAndTest(testFile, browser, false);
41
41
  if (!success) {
42
42
  failedTestFiles.push(testFile);
43
- if (!isFlaky()) {
43
+ if (!isFlaky) {
44
44
  doNotRetry = true;
45
45
  }
46
46
  if (utils_1.cliOptions.bail) {
@@ -59,7 +59,7 @@ async function runTestFiles(testFiles, browser) {
59
59
  for (let i = 0; i <= 1; i++) {
60
60
  console.log((i === 0 ? 'SECOND' : 'THIRD') + '_ATTEMPT');
61
61
  for (const testFile of failedTestFiles) {
62
- const success = await buildAndTest(testFile, browser, i === 1);
62
+ const { success } = await buildAndTest(testFile, browser, i === 1);
63
63
  if (success) {
64
64
  failedTestFiles = failedTestFiles.filter((t) => t !== testFile);
65
65
  }
@@ -68,12 +68,6 @@ async function runTestFiles(testFiles, browser) {
68
68
  return failedTestFiles;
69
69
  }
70
70
  }
71
- function isFlaky() {
72
- const testInfo = (0, getCurrentTest_1.getCurrentTest)();
73
- // Set when user calls run()
74
- (0, utils_1.assert)(testInfo.runInfo);
75
- return testInfo.runInfo.isFlaky;
76
- }
77
71
  async function buildAndTest(testFile, browser, isThirdAttempt) {
78
72
  (0, utils_1.assert)(testFile.endsWith('.ts'));
79
73
  const testFileJs = testFile.replace('.ts', '.mjs');
@@ -95,35 +89,45 @@ async function buildAndTest(testFile, browser, isThirdAttempt) {
95
89
  if (execErr) {
96
90
  (0, logTestStatus_1.logFail)(`an error was thrown while executing the file ${testFile}`, true);
97
91
  (0, logError_1.logError)(execErr);
98
- return false;
92
+ return {
93
+ success: false,
94
+ isFlaky: false,
95
+ };
99
96
  }
100
97
  // When user calls skip()
101
98
  const testInfo = (0, getCurrentTest_1.getCurrentTest)();
102
99
  if (testInfo.skipped) {
103
100
  assertSkipUsage(testInfo);
104
101
  (0, logTestStatus_1.logWarn)(testInfo.skipped.reason);
105
- return true;
102
+ return {
103
+ success: true,
104
+ isFlaky: false,
105
+ };
106
106
  }
107
107
  else {
108
108
  // Set when user calls run() or runCommandThatTerminates()
109
109
  (0, utils_1.assert)(testInfo.runInfo);
110
110
  }
111
+ const { isFlaky } = testInfo.runInfo;
111
112
  // When user calls run runCommandThatTerminates()
112
113
  if (testInfo.runInfo.isRunCommandThatTerminates) {
113
114
  (0, utils_1.assertUsage)(!testInfo.tests, "Can't call test() when calling runCommandThatTerminates()");
114
115
  (0, utils_1.assertUsage)(!testInfo.startServer, "Can't call run() when calling runCommandThatTerminates()");
115
116
  (0, logTestStatus_1.logPass)();
116
- return true;
117
+ return {
118
+ success: true,
119
+ isFlaky,
120
+ };
117
121
  }
118
- const success = await runServerAndTests(browser, isThirdAttempt);
122
+ const success = await runServerAndTests(browser, isThirdAttempt, isFlaky);
119
123
  (0, getCurrentTest_2.setCurrentTest)(null);
120
- return success;
124
+ return { success, isFlaky };
121
125
  }
122
- async function runServerAndTests(browser, isThirdAttempt) {
126
+ async function runServerAndTests(browser, isThirdAttempt, isFlaky) {
123
127
  const testInfo = (0, getCurrentTest_1.getCurrentTest)();
124
128
  (0, utils_1.assert)(testInfo.startServer);
125
129
  (0, utils_1.assert)(testInfo.terminateServer);
126
- const isFinalAttempt = isThirdAttempt || !isFlaky();
130
+ const isFinalAttempt = isThirdAttempt || !isFlaky;
127
131
  const page = await browser.newPage();
128
132
  testInfo.page = page;
129
133
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.5.19",
3
+ "version": "0.5.20",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {