|
1 | 1 | /**
|
2 |
| - * @license |
| 2 | + * @license Apache-2.0 |
3 | 3 | * Copyright 2020 The Closure Compiler Authors.
|
4 | 4 | *
|
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -74,15 +74,37 @@ describe('Runtime tests', () => {
|
74 | 74 |
|
75 | 75 | it(`should pass test suite ${path.basename(testUrl)}`, async () => {
|
76 | 76 | const { window } = new JSDOM(TEST_DOC, {
|
| 77 | + /** |
| 78 | + * This does not actually run a server of any kind, it only informs the |
| 79 | + * DOM what to put in `window.location.origin`. By default, this is |
| 80 | + * `null`, and any non-HTTPS URL field here will throw an error in the |
| 81 | + * test suite |
| 82 | + */ |
77 | 83 | url: 'https://localhost:42',
|
| 84 | + /** |
| 85 | + * This flag will allow the execution of `<script>` tags that are added |
| 86 | + * to the DOM after the `onload` event, i.e., those that are added by |
| 87 | + * `goog.module` and `goog.require`. |
| 88 | + */ |
78 | 89 | runScripts: 'dangerously',
|
| 90 | + /** |
| 91 | + * Pipe `console.log` to our virtual console. |
| 92 | + */ |
79 | 93 | virtualConsole
|
80 | 94 | });
|
81 | 95 |
|
82 | 96 | try {
|
83 | 97 | await TestIsFinished;
|
84 | 98 | } catch (e) {
|
85 |
| - fail(`Failed test in suite ${testName}: \n${chalk.red(e)}\n`); |
| 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`); |
86 | 108 | }
|
87 | 109 | console.log(`Passed all tests in suite ${testName}`);
|
88 | 110 | });
|
|
0 commit comments