Skip to content

Commit

Permalink
Switch from bun test to vitest (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Jun 1, 2024
1 parent d4941d8 commit d48ae89
Show file tree
Hide file tree
Showing 6 changed files with 696 additions and 167 deletions.
3 changes: 1 addition & 2 deletions collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
export const testableUrls = new Map<string, string[]>();

export function addTests(test: string, urls: string[]): void {
// eslint-disable-next-line n/prefer-global/process -- Better not import `process` to avoid bundling its polyfills by mistake
if (process.env.NODE_ENV !== 'bundling') {
if (import.meta.env.VITE_KEEP_URLS === '1') {
testableUrls.set(test, urls);
}
}
Expand Down
13 changes: 12 additions & 1 deletion global.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
/* eslint-disable @typescript-eslint/consistent-type-definitions -- Module augmentation */

/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly VITE_KEEP_URLS: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}

// Broaden types because testing against `"undefined"` is fine for our regexes
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- Module augmentation
interface RegExp {
test(s: string | undefined): boolean;
}
3 changes: 1 addition & 2 deletions index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference types="bun-types" />
/// <reference lib="dom" />
import assert from 'node:assert/strict';
import {test} from 'bun:test';
import {test} from 'vitest';
import stripIndent from 'strip-indent';
import {getAllUrls, getTests} from './collector.js';
import * as pageDetect from './index.js';
Expand Down
Loading

0 comments on commit d48ae89

Please sign in to comment.