Skip to content

Commit 4ca2f59

Browse files
committed
Removed test formatting, more trouble than it's worth
1 parent b42e649 commit 4ca2f59

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

utils/js/runtimeTests.js

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ const glob = require('glob');
2929
const path = require('path');
3030

3131
const TEST_FILES = glob.sync(path.resolve(
32-
__dirname,
33-
'../../test/com/google/javascript/jscomp/runtime_tests/**/build/*_test.html'
32+
__dirname,
33+
'../../test/com/google/javascript/jscomp/runtime_tests/**/build/*_test.html',
3434
));
3535

3636
describe('Runtime tests', () => {
37-
for (let testUrl of TEST_FILES) {
37+
for (const testUrl of TEST_FILES) {
3838
const logs = [];
3939
const passed = /PASSED/i;
4040
const failed = /FAILED/i;
@@ -43,37 +43,36 @@ describe('Runtime tests', () => {
4343
const chalkMsg = (msg) => {
4444
const isPass = passed.test(msg);
4545
const isFail = failed.test(msg);
46-
46+
4747
if (isPass || isFail) {
4848
return msg.replace(
49-
passed, chalk.green('PASSED')
49+
passed, chalk.green('PASSED'),
5050
).replace(
51-
failed, chalk.red('FAILED')
51+
failed, chalk.red('FAILED'),
5252
);
53-
}
54-
else return msg;
55-
}
56-
53+
} else return msg;
54+
};
55+
5756
const testName = path.basename(testUrl);
5857
const TestIsFinished = new FutureEvent();
5958
const virtualConsole = new VirtualConsole()
60-
.on('log', (msg) => {
61-
logs.push(chalkMsg(msg));
62-
if (/Tests complete/i.test(msg)) TestIsFinished.ready(allLogs());
63-
else if (/Tests failed/i.test(msg)) TestIsFinished.cancel(allLogs());
64-
});
59+
.on('log', (msg) => {
60+
logs.push(chalkMsg(msg));
61+
if (/Tests complete/i.test(msg)) TestIsFinished.ready(allLogs());
62+
else if (/Tests failed/i.test(msg)) TestIsFinished.cancel(allLogs());
63+
});
6564

6665
const TEST_DOC = fs.readFileSync(
67-
path.resolve(
68-
__dirname,
69-
'../../',
70-
testUrl
71-
),
72-
'utf-8'
66+
path.resolve(
67+
__dirname,
68+
'../../',
69+
testUrl,
70+
),
71+
'utf-8',
7372
);
7473

7574
it(`should pass test suite ${path.basename(testUrl)}`, async () => {
76-
const { window } = new JSDOM(TEST_DOC, {
75+
new JSDOM(TEST_DOC, {
7776
/**
7877
* This does not actually run a server of any kind, it only informs the
7978
* DOM what to put in `window.location.origin`. By default, this is
@@ -90,23 +89,15 @@ describe('Runtime tests', () => {
9089
/**
9190
* Pipe `console.log` to our virtual console.
9291
*/
93-
virtualConsole
92+
virtualConsole,
9493
});
9594

9695
try {
9796
await TestIsFinished;
9897
} catch (e) {
99-
// Format the error a bit: first line red, rest unformatted.
100-
const errorLines = e.toString().split('\n');
101-
let formattedError;
102-
for (let i = 0; i < errorLines.length; i++) {
103-
formattedError += i === 0
104-
? chalk.red(errorLines[i])
105-
: errorLines[i];
106-
}
107-
fail(`Failed test in suite ${testName}: \n${formattedError}\n`);
98+
fail(`Failed test in suite ${testName}: \n${e}\n`);
10899
}
109100
console.log(`Passed all tests in suite ${testName}`);
110101
});
111102
}
112-
});
103+
});

0 commit comments

Comments
 (0)