Registry / testing / yaml-test-suite

yaml-test-suite

JSON →
library0.1.0jsnpmunverified

The `yaml-test-suite` package provides a JavaScript representation of the official YAML test suite data, as defined by the YAML community. It encapsulates a comprehensive collection of YAML test cases, including their original filenames, descriptive names, source URLs, associated tags, and individual test scenarios (with YAML input and expected JSON output). Currently at version 0.1.0, this library is a relatively stable data source, primarily seeing updates when the underlying YAML test suite itself evolves or when minor structural enhancements are added (like the `id` field in 0.1.0). Its primary differentiation is offering this suite as a directly consumable JavaScript array, eliminating the need for developers to parse raw YAML test files manually, making it ideal for testing YAML parsers, linters, or other YAML-related tools within JavaScript or TypeScript environments.

testingserialization
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

The package exports its entire test suite data (an array of objects) as the default export. This is the primary way to consume it in ESM projects.

import yamlTestSuite from 'yaml-test-suite'

For CommonJS environments, `require` directly resolves to the default export. The `.default` property is generally not needed when importing the default export this way.

const yamlTestSuite = require('yaml-test-suite')

The package ships with TypeScript types. The main type for the entire suite is `YamlTestSuiteData`, which represents the array of test case objects. This is a type-only import.

import type { YamlTestSuiteData } from 'yaml-test-suite'

This quickstart code loads the entire YAML test suite and logs basic statistics, then iterates through the first few test cases to display their structure, including filenames, names, tags, and truncated YAML input/JSON output of their sub-cases.

import yamlTestSuite from 'yaml-test-suite'; console.log(`Total YAML test cases loaded: ${yamlTestSuite.length}`); // Iterate and log details of the first 3 test cases to demonstrate structure for (let i = 0; i < Math.min(3, yamlTestSuite.length); i++) { const testCase = yamlTestSuite[i]; console.log(`\n--- Test Case ${i + 1} ---`); console.log(`Filename: ${testCase.filename}`); console.log(`Name: ${testCase.name}`); console.log(`Source: ${testCase.from}`); console.log(`Tags: ${testCase.tags.join(', ')}`); console.log(`Number of sub-cases: ${testCase.cases.length}`); if (testCase.cases.length > 0) { // Log a truncated version of the YAML input and expected JSON output console.log(`First sub-case input YAML (truncated):\n${testCase.cases[0].yaml?.substring(0, 100) || ''}...`); console.log(`First sub-case JSON output (truncated):\n${JSON.stringify(testCase.cases[0].json)?.substring(0, 100) || ''}...`); } }
Debug
Known footguns
gotchaThe package is currently in an early development phase (v0.1.0). While it provides a stable dataset, the internal structure of the exported data objects (e.g., specific fields within each test case or sub-case) might undergo minor non-breaking changes in future 0.x releases. The overall array structure and general purpose are expected to remain consistent, but specific property access might need adjustment.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
15 hits · last 30 days
gptbot
4
ahrefsbot
4
amazonbot
4
script
1
bingbot
1
mj12bot
1
Resources