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, //i); assert.match(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(/^\//, ''))), ), ); });