26 lines
828 B
JavaScript
26 lines
828 B
JavaScript
import assert from 'node:assert/strict';
|
|
import { existsSync, readFileSync } from 'node:fs';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const dist = fileURLToPath(new URL('../dist/', import.meta.url));
|
|
const html = readFileSync(
|
|
new URL('../dist/index.html', import.meta.url),
|
|
'utf8'
|
|
);
|
|
const assets = [...html.matchAll(/(?:href|src)="(\/assets\/[^"]+)"/g)].map(
|
|
match => match[1]
|
|
);
|
|
|
|
assert.match(html, /<div id="app"><\/div>/);
|
|
assert.match(html, /<script src="\/runtime-config\.js"><\/script>/);
|
|
assert.ok(
|
|
assets.some(asset => asset.endsWith('.js')),
|
|
'missing JS asset'
|
|
);
|
|
assert.ok(
|
|
assets.some(asset => asset.endsWith('.css')),
|
|
'missing CSS asset'
|
|
);
|
|
assert.ok(!/<script(?![^>]*\bsrc=)[^>]*>/i.test(html), 'inline script found');
|
|
assets.forEach(asset => assert.ok(existsSync(dist + asset.slice(1)), asset));
|