()
| 270 | |
| 271 | |
| 272 | async function start() { |
| 273 | // Clean PR directories before starting |
| 274 | const {cleanPRDirectories} = require('./util'); |
| 275 | cleanPRDirectories(); |
| 276 | |
| 277 | if (!checkPuppeteer()) { |
| 278 | console.error(`Can't find puppeteer >= 9.0.0, run 'npm install' to update in the 'test/runTest' folder`); |
| 279 | return; |
| 280 | } |
| 281 | |
| 282 | let stableVersions; |
| 283 | let nightlyVersions; |
| 284 | try { |
| 285 | stableVersions = await fetchVersions(false, useCNMirror); |
| 286 | nightlyVersions = (await fetchVersions(true, useCNMirror)).slice(0, 100); |
| 287 | } catch (e) { |
| 288 | console.error('Failed to fetch version list:', e); |
| 289 | console.log(`Try again later or try the CN mirror with: ${chalk.yellow('npm run test:visual -- -- --useCNMirror')}`) |
| 290 | return; |
| 291 | } |
| 292 | |
| 293 | let _currentTestHash; |
| 294 | let _currentRunConfig; |
| 295 | |
| 296 | // let runtimeCode = await buildRuntimeCode(); |
| 297 | // fse.outputFileSync(path.join(__dirname, 'tmp/testRuntime.js'), runtimeCode, 'utf-8'); |
| 298 | |
| 299 | // Start a static server for puppeteer open the html test cases. |
| 300 | let {io} = serve(); |
| 301 | |
| 302 | io.of('/client').on('connect', async socket => { |
| 303 | |
| 304 | let isAborted = false; |
| 305 | function abortTests() { |
| 306 | if (!isRunning()) { |
| 307 | return; |
| 308 | } |
| 309 | isAborted = true; |
| 310 | stopRunningTests(); |
| 311 | io.of('/client').emit('abort'); |
| 312 | } |
| 313 | |
| 314 | socket.on('syncRunConfig', async ({ |
| 315 | runConfig, |
| 316 | forceSet |
| 317 | }) => { |
| 318 | // First time open. |
| 319 | if ((!_currentRunConfig || forceSet) && runConfig) { |
| 320 | _currentRunConfig = runConfig; |
| 321 | } |
| 322 | |
| 323 | if (!_currentRunConfig) { |
| 324 | return; |
| 325 | } |
| 326 | |
| 327 | socket.emit('syncRunConfig_return', { |
| 328 | runConfig: _currentRunConfig, |
| 329 | versions: stableVersions, |
no test coverage detected
searching dependent graphs…