Skip to content

Add npm test script and example validation test against meta-schema#7

Open
BelfordZ wants to merge 1 commit intomasterfrom
fix/add-npm-test-script-and-suite
Open

Add npm test script and example validation test against meta-schema#7
BelfordZ wants to merge 1 commit intomasterfrom
fix/add-npm-test-script-and-suite

Conversation

@BelfordZ
Copy link
Copy Markdown
Member

Motivation

  • Ensure every JSON example in src/examples is valid against the repository's src/meta-schema.json by adding a test that exercises every example.
  • Provide a standard way to run tests via an npm test script so CI and contributors can validate examples easily.

Description

  • Added a test npm script ("test": "node --test") to package.json to run the Node test runner.
  • Added dev dependencies ajv and ajv-formats and recorded changes to package-lock.json to support JSON Schema validation in tests.
  • Introduced test/examples-meta-schema.test.mjs, a Node test which loads src/meta-schema.json, discovers each *.json file in src/examples, and validates each example with Ajv, failing with readable errors if validation fails.
  • Made validation deterministic/offline-friendly by registering the draft-07 meta-schema under the https://meta.json-schema.tools (with and without trailing slash) reference and enabling formats via ajv-formats.

Testing

  • Ran npm install to install added dev dependencies, which completed successfully.
  • Ran npm test during development; initial run failed due to Ajv attempting to fetch the external meta-schema, which led to a fix mapping https://meta.json-schema.tools to the bundled draft-07 schema.
  • After the fix, npm test succeeded and the suite reported all validations passing (all example files in src/examples validated successfully).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant