* @returns {void}
()
| 120 | * @returns {void} |
| 121 | */ |
| 122 | write() { |
| 123 | this.time_end = Date.now(); |
| 124 | const results = Array.from(this.results.values()) |
| 125 | .map((result) => { |
| 126 | const url = new URL(result.test, 'http://wpt'); |
| 127 | url.pathname = url.pathname.replace(/\.js$/, '.html'); |
| 128 | result.test = url.href.slice(url.origin.length); |
| 129 | return result; |
| 130 | }); |
| 131 | |
| 132 | /** |
| 133 | * Return required and some optional properties |
| 134 | * https://github.com/web-platform-tests/wpt.fyi/blob/60da175/api/README.md?plain=1#L331-L335 |
| 135 | */ |
| 136 | this.run_info = { |
| 137 | product: 'node.js', |
| 138 | ...getBrowserProperties(), |
| 139 | revision: process.env.WPT_REVISION || 'unknown', |
| 140 | os: getOs(), |
| 141 | }; |
| 142 | |
| 143 | fs.writeFileSync(this.filepath, JSON.stringify({ |
| 144 | time_start: this.time_start, |
| 145 | time_end: this.time_end, |
| 146 | run_info: this.run_info, |
| 147 | results: results, |
| 148 | })); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // https://github.com/web-platform-tests/wpt/blob/HEAD/resources/testharness.js |
no test coverage detected