Skip to content

Commit fe42716

Browse files
committed
Final comments added
1 parent a635e42 commit fe42716

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

utils/js/runtimeTests.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,19 @@ describe('Runtime tests', () => {
5454
} else return msg;
5555
};
5656

57+
// file.ext -> file
5758
const testName = path.basename(testFile);
59+
// A promise that will resolve when JSDOM is done executing.
5860
const testIsFinished = new FutureEvent();
61+
// A virtual console which will receive messages from JSDOM's `console.log`.
5962
const virtualConsole = new VirtualConsole()
6063
.on('log', (msg) => {
6164
logs.push(chalkMsg(msg));
6265
if (/Tests complete/i.test(msg)) testIsFinished.ready(allLogs());
6366
else if (/Tests failed/i.test(msg)) testIsFinished.cancel(allLogs());
6467
});
6568

69+
// Load the generated test file for consumption by the JSDOM environment.
6670
const testDocument = fs.readFileSync(
6771
path.resolve(
6872
__dirname,
@@ -94,10 +98,13 @@ describe('Runtime tests', () => {
9498
});
9599

96100
try {
101+
// Wait for test to finish.
97102
await testIsFinished;
98103
} catch (e) {
104+
// If there was an error, print it.
99105
fail(`Failed test in suite ${testName}: \n${e}\n`);
100106
}
107+
// Otherwise, everything passed.
101108
console.log(`Passed all tests in suite ${testName}`);
102109
});
103110
}

0 commit comments

Comments
 (0)