Skip to content

Commit c1eef94

Browse files
committed
test: Validate HTML files
1 parent c48b320 commit c1eef94

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

bun.lockb

376 Bytes
Binary file not shown.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@eslint/js": "9.17.0",
2929
"@maxmilton/eslint-config": "0.0.8",
3030
"@maxmilton/stylelint-config": "0.1.2",
31-
"@maxmilton/test-utils": "0.0.6",
31+
"@maxmilton/test-utils": "0.0.7",
3232
"@playwright/test": "1.49.1",
3333
"@types/bun": "1.1.14",
3434
"@types/chrome": "0.0.287",

test/unit/index.test.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, test } from 'bun:test';
22
import { readdir } from 'node:fs/promises';
3+
import { validate } from '@maxmilton/test-utils/html';
34

45
describe('dist files', () => {
56
// FIXME: The bun file type is just inferred from the file extension, not the
@@ -49,8 +50,17 @@ describe('dist files', () => {
4950
const distDir = await readdir('dist');
5051
expect(distDir).toHaveLength(distFiles.length);
5152
});
53+
54+
test.each(distFiles.filter(([filename]) => filename.endsWith('.html')))(
55+
'%s contains valid HTML',
56+
async (filename) => {
57+
const file = Bun.file(`dist/${filename}`);
58+
const html = await file.text();
59+
const result = validate(html);
60+
expect(result.valid).toBeTrue();
61+
},
62+
);
5263
});
5364

54-
// TODO: HTML files should be valid HTML
5565
// TODO: HTML files have correct title
5666
// TODO: HTML files have correct JS and CSS file references

0 commit comments

Comments
 (0)