mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-21 05:10:39 +00:00
test: run frontend unit tests in browsers (#38860)
Run them in headless [vitest browser mode](https://vitest.dev/guide/browser/) in chromium and firefox. Similar UX than current tests, it's about 5 times as slow (goes from 1s to 5s on my machine), but definitely worth it as it removes all happy-dom problems. --------- Signed-off-by: silverwind <me@silverwind.io>
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import {readFile} from 'node:fs/promises';
|
||||
import * as path from 'node:path';
|
||||
import globTestData from './glob.test.txt';
|
||||
import {globCompile} from './glob.ts';
|
||||
|
||||
async function loadGlobTestData(): Promise<{caseNames: string[], caseDataMap: Record<string, string>}> {
|
||||
const fileContent = await readFile(path.join(import.meta.dirname, 'glob.test.txt'), 'utf8');
|
||||
const fileLines = fileContent.split('\n');
|
||||
function loadGlobTestData(): {caseNames: string[], caseDataMap: Record<string, string>} {
|
||||
const fileLines = globTestData.split('\n');
|
||||
const caseDataMap: Record<string, string> = {};
|
||||
const caseNameMap: Record<string, boolean> = {};
|
||||
for (let line of fileLines) {
|
||||
@@ -103,8 +101,8 @@ function loadGlobGolangCases() {
|
||||
];
|
||||
}
|
||||
|
||||
test('GlobCompiler', async () => {
|
||||
const {caseNames, caseDataMap} = await loadGlobTestData();
|
||||
test('GlobCompiler', () => {
|
||||
const {caseNames, caseDataMap} = loadGlobTestData();
|
||||
expect(caseNames.length).toBe(10); // should have 10 test cases
|
||||
for (const caseName of caseNames) {
|
||||
const pattern = caseDataMap[`pattern_${caseName}`];
|
||||
|
||||
Reference in New Issue
Block a user