chore(tooling): modernize Next verification setup
This commit is contained in:
26
tests/static-export.test.mjs
Normal file
26
tests/static-export.test.mjs
Normal file
@@ -0,0 +1,26 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { access, readFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
|
||||
const exportRoot = path.resolve('out');
|
||||
|
||||
test('the production build exports a usable home page', async () => {
|
||||
const indexPath = path.join(exportRoot, 'index.html');
|
||||
const html = await readFile(indexPath, 'utf8');
|
||||
|
||||
assert.match(html, /<!DOCTYPE html>/i);
|
||||
assert.match(html, /<html[^>]*lang=/i);
|
||||
|
||||
const assetPaths = [
|
||||
...html.matchAll(/(?:src|href)="(\/_next\/static\/[^"?#]+)/g),
|
||||
].map((match) => match[1]);
|
||||
|
||||
assert.ok(assetPaths.length > 0, 'expected the home page to reference built assets');
|
||||
|
||||
await Promise.all(
|
||||
[...new Set(assetPaths)].map((assetPath) =>
|
||||
access(path.join(exportRoot, assetPath.replace(/^\//, ''))),
|
||||
),
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user