Files
feuerwerk/tools/e2e/41-physics.mjs
T

29 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* The physics engine (Rapier) loads in the editor, in the background after the first project is
* open, from a chunk of its own – the editor bundle does not carry it.
*/
export async function physics(t) {
const { check, json, waitUntil, consoleLog } = t;
await waitUntil(`['ready', 'failed'].includes(__gm.physics().state)`, { timeout: 15000 });
const status = await json('__gm.physics()');
check(
'Rapier loads in the editor without Play',
status.state === 'ready' && status.version === '0.20.0',
JSON.stringify(status),
);
const scripts = await json(
`performance.getEntriesByType('resource').map((e) => e.name).filter((n) => n.endsWith('.js')).map((n) => n.split('/').pop())`,
);
check(
'it comes from a chunk of its own',
scripts.some((name) => /^rapier-.+\.js$/.test(name)),
JSON.stringify(scripts),
);
check(
'loading it writes nothing to the console',
!consoleLog.some((line) => /\[physics\]|rapier/i.test(line)),
consoleLog.filter((line) => /\[physics\]|rapier/i.test(line)).join(' | '),
);
}