|
1 |
| -import Mocha from 'mocha'; |
| 1 | +import fs from 'node:fs'; |
| 2 | +import { execute } from '../build/execute.js'; |
2 | 3 |
|
3 |
| -import { create, globals } from '../index.js'; |
| 4 | +const cwd = process.cwd(); |
4 | 5 |
|
5 |
| -Object.assign(globalThis, globals); |
6 |
| -globalThis.navigator = { gpu: create([]) }; |
| 6 | +await execute('node', ['test/functional-tests.js']); |
7 | 7 |
|
8 |
| -const mocha = new Mocha({}); |
| 8 | +const tsTestsDir = 'test/ts-tests'; |
| 9 | +const tests = fs.readdirSync(tsTestsDir, { withFileTypes: true }) |
| 10 | + .filter(t => t.isDirectory()) |
| 11 | + .map(t => `${tsTestsDir}/${t.name}`); |
9 | 12 |
|
10 |
| -mocha.addFile('./test/tests/basic-tests.js'); |
| 13 | +for (const test of tests) { |
| 14 | + console.log('testing:', test); |
| 15 | + process.chdir(test); |
| 16 | + fs.rmSync('node_modules', { recursive: true, force: true }); |
| 17 | + await execute('npm', ['i', '--no-package-lock']); |
| 18 | + await execute('npm', ['test']); |
| 19 | + process.chdir(cwd); |
| 20 | +} |
11 | 21 |
|
12 |
| -await mocha.loadFilesAsync(); |
13 |
| -mocha.run(failures => { |
14 |
| - delete globalThis.navigator; |
15 |
| - process.exit(failures); |
16 |
| -}); |
|
0 commit comments