Skip to content

Commit 4cbf078

Browse files
committed
fixup! test: add some validation for JSON doc output
1 parent 38d824e commit 4cbf078

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/parallel/test-doc-api-json.mjs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import '../common/index.mjs';
1+
import * as common from '../common/index.mjs';
22

33
import assert from 'node:assert';
44
import { existsSync } from 'node:fs';
@@ -8,6 +8,10 @@ import path from 'node:path';
88
// This tests that `make doc` generates the JSON documentation properly.
99
// Note that for this test to pass, `make doc` must be run first.
1010

11+
if (common.isWindows) {
12+
common.skip('`make doc` does not run on Windows');
13+
}
14+
1115
function validateModule(module) {
1216
assert.strictEqual(typeof module, 'object');
1317
assert.strictEqual(module.type, 'module');
@@ -120,7 +124,14 @@ for await (const dirent of await fs.opendir(new URL('../../out/doc/api/', import
120124
}
121125

122126
console.log('testing', jsonPath, 'based on', expectedSource);
123-
const json = JSON.parse(await fs.readFile(jsonPath, 'utf8'));
127+
128+
const fileContent = await fs.readFile(jsonPath, 'utf8');
129+
// A proxy to check if the file is human readable is to count if it contains
130+
// at least 3 line return.
131+
assert.strictEqual(fileContent.split('\n', 3).length, 3);
132+
assert.ok(fileContent.endsWith('\n'), 'EOL at EOF');
133+
134+
const json = JSON.parse(fileContent);
124135

125136
assert.strictEqual(json.type, 'module');
126137
assert.strictEqual(json.source, expectedSource);

0 commit comments

Comments
 (0)