@brillout/test-e2e 0.1.3 → 0.1.4
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.js +3 -3
- package/dist/getBrowser.js +2 -2
- package/dist/runTests.js +12 -12
- package/dist/setup.js +1 -2
- package/dist/utils/findFiles.js +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/logProgress.d.ts +2 -0
- package/dist/{logProgress.js → utils/logProgress.js} +5 -16
- package/package.json +8 -6
- package/dist/logProgress.d.ts +0 -2
package/dist/Logs.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.Logs = {
|
|
|
9
9
|
flushEagerly: false,
|
|
10
10
|
};
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
-
const
|
|
12
|
+
const picocolors_1 = require("picocolors");
|
|
13
13
|
let logEntries = [];
|
|
14
14
|
let logEntriesNotPrinted = [];
|
|
15
15
|
function getBrowserErrors() {
|
|
@@ -61,9 +61,9 @@ function printLog(logEntry) {
|
|
|
61
61
|
const { logType, logText, logTimestamp, testContext } = logEntry;
|
|
62
62
|
let prefix = logType;
|
|
63
63
|
if (logType === 'stderr' || logType === 'Browser Error')
|
|
64
|
-
prefix = (0,
|
|
64
|
+
prefix = (0, picocolors_1.bold)((0, picocolors_1.red)(logType));
|
|
65
65
|
if (logType === 'stdout' || logType === 'Browser Log')
|
|
66
|
-
prefix = (0,
|
|
66
|
+
prefix = (0, picocolors_1.bold)((0, picocolors_1.blue)(logType));
|
|
67
67
|
let msg = logText;
|
|
68
68
|
if (!msg)
|
|
69
69
|
msg = ''; // don't know why but sometimes `logText` is `undefined`
|
package/dist/getBrowser.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getBrowser = void 0;
|
|
4
4
|
const playwright_chromium_1 = require("playwright-chromium");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
6
|
let browser;
|
|
7
7
|
async function getBrowser() {
|
|
8
8
|
if (!browser) {
|
|
9
|
-
const done = (0,
|
|
9
|
+
const done = (0, utils_1.logProgress)('Launch Browser');
|
|
10
10
|
browser = await playwright_chromium_1.chromium.launch({ headless: true });
|
|
11
11
|
done();
|
|
12
12
|
}
|
package/dist/runTests.js
CHANGED
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runTests = void 0;
|
|
4
4
|
const getTestInfo_1 = require("./getTestInfo");
|
|
5
|
-
const logProgress_1 = require("./logProgress");
|
|
6
5
|
const Logs_1 = require("./Logs");
|
|
7
6
|
const utils_1 = require("./utils");
|
|
8
7
|
const expect_1 = require("./chai/expect");
|
|
9
|
-
const
|
|
10
|
-
const iconSuccess = '✅';
|
|
11
|
-
const iconFailure = '❌';
|
|
8
|
+
const picocolors_1 = require("picocolors");
|
|
12
9
|
async function runTests(browser) {
|
|
13
10
|
const testInfo = (0, getTestInfo_1.getTestInfo)();
|
|
14
11
|
if (utils_1.isTTY) {
|
|
@@ -21,7 +18,7 @@ async function runTests(browser) {
|
|
|
21
18
|
if (testInfo.skipped) {
|
|
22
19
|
(0, utils_1.assertUsage)(!testInfo.runWasCalled, 'You cannot call `run()` after calling `skip()`');
|
|
23
20
|
(0, utils_1.assertUsage)(testInfo.tests === undefined, 'You cannot call `test()` after calling `skip()`');
|
|
24
|
-
|
|
21
|
+
logTestsResult(false);
|
|
25
22
|
return;
|
|
26
23
|
}
|
|
27
24
|
// Set when user calls `run()`
|
|
@@ -34,7 +31,7 @@ async function runTests(browser) {
|
|
|
34
31
|
(0, utils_1.assert)(testInfo.tests);
|
|
35
32
|
await testInfo.beforeAll();
|
|
36
33
|
for (const { testDesc, testFn } of testInfo.tests) {
|
|
37
|
-
const done = (0,
|
|
34
|
+
const done = (0, utils_1.logProgress)(` | [test] ${testDesc}`);
|
|
38
35
|
let err;
|
|
39
36
|
try {
|
|
40
37
|
await runTest(testFn, testInfo.testTimeout);
|
|
@@ -51,7 +48,7 @@ async function runTests(browser) {
|
|
|
51
48
|
}
|
|
52
49
|
Logs_1.Logs.clear();
|
|
53
50
|
if (isFailure) {
|
|
54
|
-
|
|
51
|
+
logTestsResult(false);
|
|
55
52
|
if (browserErrors.length === 0) {
|
|
56
53
|
throw err;
|
|
57
54
|
}
|
|
@@ -67,7 +64,7 @@ async function runTests(browser) {
|
|
|
67
64
|
}
|
|
68
65
|
await testInfo.afterAll();
|
|
69
66
|
await page.close();
|
|
70
|
-
|
|
67
|
+
logTestsResult(true);
|
|
71
68
|
}
|
|
72
69
|
exports.runTests = runTests;
|
|
73
70
|
function runTest(testFn, testTimeout) {
|
|
@@ -95,17 +92,20 @@ function runTest(testFn, testTimeout) {
|
|
|
95
92
|
})();
|
|
96
93
|
return promise;
|
|
97
94
|
}
|
|
98
|
-
function
|
|
95
|
+
function logTestsResult(success) {
|
|
99
96
|
const testInfo = (0, getTestInfo_1.getTestInfo)();
|
|
97
|
+
const passStyle = (t) => (0, picocolors_1.white)((0, picocolors_1.bgGreen)(t));
|
|
98
|
+
const failStyle = (t) => (0, picocolors_1.white)((0, picocolors_1.bgRed)(t));
|
|
99
|
+
const skipStyle = (t) => (0, picocolors_1.white)((0, picocolors_1.bgYellow)(t));
|
|
100
100
|
if (success) {
|
|
101
101
|
(0, utils_1.assert)(!testInfo.skipped);
|
|
102
|
-
console.log(`${
|
|
102
|
+
console.log(`${passStyle('PASS')} ${testInfo.testFile}`);
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
105
|
if (testInfo.skipped) {
|
|
106
|
-
console.log(`${
|
|
106
|
+
console.log(`${skipStyle('SKIP')} ${testInfo.testFile} (${testInfo.skipped})`);
|
|
107
107
|
}
|
|
108
108
|
else {
|
|
109
|
-
console.log(`${
|
|
109
|
+
console.log(`${failStyle('FAIL')} ${testInfo.testFile}`);
|
|
110
110
|
}
|
|
111
111
|
}
|
package/dist/setup.js
CHANGED
|
@@ -15,7 +15,6 @@ const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
|
15
15
|
const editFile_1 = require("./editFile");
|
|
16
16
|
const getTestInfo_1 = require("./getTestInfo");
|
|
17
17
|
const page_1 = require("./page");
|
|
18
|
-
const logProgress_1 = require("./logProgress");
|
|
19
18
|
var part_regex_1 = require("@brillout/part-regex");
|
|
20
19
|
Object.defineProperty(exports, "partRegex", { enumerable: true, get: function () { return part_regex_1.partRegex; } });
|
|
21
20
|
var Logs_2 = require("./Logs");
|
|
@@ -189,7 +188,7 @@ async function start(testContext) {
|
|
|
189
188
|
if (!process.env.CI && isLinux()) {
|
|
190
189
|
await (0, utils_1.runCommand)('fuser -k 3000/tcp', { swallowError: true, timeout: 10 * 1000 });
|
|
191
190
|
}
|
|
192
|
-
const done = (0,
|
|
191
|
+
const done = (0, utils_1.logProgress)(` | [run] ${cmd}`);
|
|
193
192
|
const { terminate } = startScript(cmd, testContext, {
|
|
194
193
|
onError(err) {
|
|
195
194
|
rejectServerStart(err);
|
package/dist/utils/findFiles.js
CHANGED
|
@@ -24,7 +24,7 @@ async function filterGitIgnoredFiles(files) {
|
|
|
24
24
|
// - In other words, we remove git ignored files. (Staged files are tracked and listed by `$ git ls-files`.)
|
|
25
25
|
// - `git ls-files --others --exclude-standard` from https://stackoverflow.com/questions/3801321/git-list-only-untracked-files-also-custom-commands/3801554#3801554
|
|
26
26
|
const stdout2 = await (0, runCommand_1.runCommand)('git ls-files --others --exclude-standard', { cwd });
|
|
27
|
-
gitFiles = [...stdout1.split('
|
|
27
|
+
gitFiles = [...stdout1.split('\n'), ...stdout2.split('\n')].map((filePathRelative) => path_1.default.join(cwd, filePathRelative));
|
|
28
28
|
}
|
|
29
29
|
const filesFiltered = files.filter((file) => gitFiles.includes(file));
|
|
30
30
|
return filesFiltered;
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.logProgress = void 0;
|
|
4
|
-
const
|
|
5
|
-
const utils_1 = require("./utils");
|
|
4
|
+
const isTTY_1 = require("./isTTY");
|
|
6
5
|
const iconSuccess = '🟢';
|
|
7
6
|
const iconPending = '🟠';
|
|
8
7
|
const iconFail = '🔴';
|
|
9
|
-
function logProgress(text
|
|
10
|
-
|
|
11
|
-
if (utils_1.isTTY) {
|
|
8
|
+
function logProgress(text) {
|
|
9
|
+
if (!isTTY_1.isTTY) {
|
|
12
10
|
const done = () => { };
|
|
13
11
|
return done;
|
|
14
12
|
}
|
|
15
|
-
process.stdout.write(`${
|
|
13
|
+
process.stdout.write(`${iconPending} ${text}`);
|
|
16
14
|
let alreadyDone = false;
|
|
17
15
|
const done = (failed) => {
|
|
18
16
|
if (alreadyDone)
|
|
@@ -20,20 +18,11 @@ function logProgress(text, isSetup) {
|
|
|
20
18
|
alreadyDone = true;
|
|
21
19
|
clear();
|
|
22
20
|
const iconDone = failed ? iconFail : iconSuccess;
|
|
23
|
-
process.stdout.write(`${
|
|
21
|
+
process.stdout.write(`${iconDone} ${text}\n`);
|
|
24
22
|
};
|
|
25
23
|
return done;
|
|
26
24
|
}
|
|
27
25
|
exports.logProgress = logProgress;
|
|
28
|
-
function getPrefix(isSetup) {
|
|
29
|
-
if (isSetup) {
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
if (!(0, getTestInfo_1.getTestInfo)()) {
|
|
33
|
-
return '';
|
|
34
|
-
}
|
|
35
|
-
return ' | ';
|
|
36
|
-
}
|
|
37
26
|
function clear() {
|
|
38
27
|
// @ts-ignore
|
|
39
28
|
process.stdout.clearLine();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brillout/test-e2e",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"bin": "./bin.js",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,17 +14,19 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@brillout/part-regex": "^0.1.2",
|
|
17
|
-
"@types/chai": "^4.3.3",
|
|
18
|
-
"@types/node": "^15.6.1",
|
|
19
|
-
"@types/node-fetch": "^2.5.12",
|
|
20
17
|
"chai": "^4.3.6",
|
|
21
18
|
"esbuild": "^0.15.9",
|
|
22
19
|
"fast-glob": "^3.2.12",
|
|
23
|
-
"kolorist": "^1.4.1",
|
|
24
20
|
"node-fetch": "^2.6.1",
|
|
21
|
+
"picocolors": "^1.0.0",
|
|
25
22
|
"playwright-chromium": "^1.22.2",
|
|
26
23
|
"source-map-support": "^0.5.21",
|
|
27
|
-
"strip-ansi": "^6.0.1"
|
|
24
|
+
"strip-ansi": "^6.0.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/chai": "^4.3.3",
|
|
28
|
+
"@types/node": "^15.6.1",
|
|
29
|
+
"@types/node-fetch": "^2.5.12",
|
|
28
30
|
"typescript": "^4.8.3"
|
|
29
31
|
},
|
|
30
32
|
"repository": "github:brillout/test-e2e",
|
package/dist/logProgress.d.ts
DELETED