* Closes all projects and exit the process * @param force If true, the process will exit immediately after closing the projects.
(force = false)
| 1536 | * @param force If true, the process will exit immediately after closing the projects. |
| 1537 | */ |
| 1538 | public async exit(force = false): Promise<void> { |
| 1539 | setTimeout(() => { |
| 1540 | this.report('onProcessTimeout').then(() => { |
| 1541 | console.warn(`close timed out after ${this.config.teardownTimeout}ms`) |
| 1542 | |
| 1543 | if (!this.pool) { |
| 1544 | const runningServers = [this._vite, ...this.projects.map(p => p._vite)].filter(Boolean).length |
| 1545 | |
| 1546 | if (runningServers === 1) { |
| 1547 | console.warn('Tests closed successfully but something prevents Vite server from exiting') |
| 1548 | } |
| 1549 | else if (runningServers > 1) { |
| 1550 | console.warn(`Tests closed successfully but something prevents ${runningServers} Vite servers from exiting`) |
| 1551 | } |
| 1552 | else { |
| 1553 | console.warn('Tests closed successfully but something prevents the main process from exiting') |
| 1554 | } |
| 1555 | |
| 1556 | if (!this.reporters.some(r => r instanceof HangingProcessReporter)) { |
| 1557 | console.warn('You can try to identify the cause by enabling "hanging-process" reporter. See https://vitest.dev/guide/reporters.html#hanging-process-reporter') |
| 1558 | } |
| 1559 | } |
| 1560 | |
| 1561 | process.exit() |
| 1562 | }) |
| 1563 | }, this.config.teardownTimeout).unref() |
| 1564 | |
| 1565 | await this.close() |
| 1566 | if (force) { |
| 1567 | process.exit() |
| 1568 | } |
| 1569 | } |
| 1570 | |
| 1571 | /** @internal */ |
| 1572 | async report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>) { |
no test coverage detected