chore: migrate api-net-session-spec.ts to vitest

This commit is contained in:
Samuel Attard
2026-04-11 22:59:00 -07:00
parent 220171a697
commit f8d0d2d599

View File

@@ -1,6 +1,7 @@
import { net, session, BrowserWindow, ClientRequestConstructorOptions } from 'electron/main';
import { expect } from 'chai';
import { afterEach, beforeEach, describe, it } from 'vitest';
import * as dns from 'node:dns';
@@ -14,14 +15,12 @@ describe('net module (session)', () => {
beforeEach(() => {
respondNTimes.routeFailure = false;
});
afterEach(async function () {
afterEach(async (ctx) => {
await session.defaultSession.clearCache();
if (respondNTimes.routeFailure && this.test) {
if (!this.test.isFailed()) {
throw new Error(
'Failing this test due an unhandled error in the respondOnce route handler, check the logs above for the actual error'
);
}
if (respondNTimes.routeFailure && ctx.task.result?.state !== 'fail') {
throw new Error(
'Failing this test due an unhandled error in the respondOnce route handler, check the logs above for the actual error'
);
}
});