| 1234567891011121314151617181920 |
- const base = 'http://localhost:4173/web/index.html';
- const response = await fetch(base);
- if (!response.ok) throw new Error(`preview page returned ${response.status}`);
- const html = await response.text();
- const script = html.match(/<script>([\s\S]*)<\/script>/)?.[1];
- if (!script) throw new Error('missing inline game script');
- new Function(script);
- const assetUrls = [...html.matchAll(/'\.\.\/assets\/resources\/sprites\/([^']+)'/g)]
- .map((m) => new URL(`../assets/resources/sprites/${m[1]}`, base).href);
- for (const url of assetUrls) {
- const asset = await fetch(url);
- if (!asset.ok) throw new Error(`asset failed: ${url} -> ${asset.status}`);
- const type = asset.headers.get('content-type') || '';
- if (!type.includes('image/png')) throw new Error(`asset is not png: ${url} (${type})`);
- }
- console.log(`web smoke passed: ${assetUrls.length} png assets loaded`);
|