-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathworker.spec.ts
More file actions
34 lines (29 loc) · 1.3 KB
/
worker.spec.ts
File metadata and controls
34 lines (29 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
export const description = `
Tests WebGPU is available in a worker.
Note: The CTS test can be run in a worker by passing in worker=1 as
a query parameter. This test is specifically to check that WebGPU
is available in a worker.
`;
import { Fixture } from '../../../common/framework/fixture.js';
import { makeTestGroup } from '../../../common/framework/test_group.js';
import { assert } from '../../../common/util/util.js';
export const g = makeTestGroup(Fixture);
function isNode(): boolean {
return typeof process !== 'undefined' && process?.versions?.node !== undefined;
}
g.test('worker')
.desc(`test WebGPU is available in DedicatedWorkers and check for basic functionality`)
.fn(async t => {
if (isNode()) {
t.skip('node does not support 100% compatible workers');
return;
}
// Note: we load worker_launcher dynamically because ts-node support
// is using commonjs which doesn't support import.meta. Further,
// we need to put the url in a string add pass the string to import
// otherwise typescript tries to parse the file which again, fails.
const url = './worker_launcher.js';
const { launchWorker } = await import(url);
const result = await launchWorker();
assert(result.error === undefined, `should be no error from worker but was: ${result.error}`);
});