Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! test: add some validation for JSON doc output
  • Loading branch information
aduh95 committed Jan 18, 2026
commit 4cbf07825b38554b8538d872a501b03363581414
15 changes: 13 additions & 2 deletions test/parallel/test-doc-api-json.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../common/index.mjs';
import * as common from '../common/index.mjs';
Comment thread
aduh95 marked this conversation as resolved.
Resolved

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

if (common.isWindows) {
common.skip('`make doc` does not run on Windows');
}

function validateModule(module) {
assert.strictEqual(typeof module, 'object');
assert.strictEqual(module.type, 'module');
Expand Down Expand Up @@ -120,7 +124,14 @@ for await (const dirent of await fs.opendir(new URL('../../out/doc/api/', import
}

console.log('testing', jsonPath, 'based on', expectedSource);
const json = JSON.parse(await fs.readFile(jsonPath, 'utf8'));

const fileContent = await fs.readFile(jsonPath, 'utf8');
// A proxy to check if the file is human readable is to count if it contains
// at least 3 line return.
assert.strictEqual(fileContent.split('\n', 3).length, 3);
assert.ok(fileContent.endsWith('\n'), 'EOL at EOF');

const json = JSON.parse(fileContent);

assert.strictEqual(json.type, 'module');
assert.strictEqual(json.source, expectedSource);
Expand Down
Loading