JSON-LD Conformance Test Suite

1.0.1 · abandoned · verified Tue Apr 21

The `json-ld-test-suite` npm package provides a snapshot of the official JSON-LD Conformance Test Suite, designed to verify the compliance of JSON-LD processors against the JSON-LD 1.0 and 1.1 specifications. While this specific npm package (version 1.0.1) was last published over eight years ago and is effectively abandoned, the underlying JSON-LD Test Suite on GitHub (json-ld/json-ld.org) remains actively maintained and updated by the JSON-LD community. This suite is crucial for implementers, offering test cases for operations such as compaction, expansion, framing, normalization, and RDF conversion. It differentiates itself by being the authoritative W3C test suite, essential for ensuring interoperability and specification adherence across different JSON-LD processor implementations, though consumers of *this npm package* should be aware of its static nature.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to programmatically load the `json-ld-test-suite` manifest and individual test files from the file system, typically for building a conformance testing harness. This snippet uses Node.js `fs` and `path` modules to read JSON-LD and SPARQL files as raw data.

import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = fileURLToPath(new URL('.', import.meta.url));

// Assuming the package is installed at node_modules/json-ld-test-suite
const packageRoot = join(__dirname, '../node_modules/json-ld-test-suite');

// Load the main manifest for all tests
const manifestPath = join(packageRoot, 'tests/manifest.jsonld');
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));

console.log(`Loaded JSON-LD Test Suite Manifest (v${manifest.version || 'unknown'})`);
console.log(`Number of manifests: ${manifest.sequence.length}`);

// Example: Accessing a specific test entry
const firstManifest = manifest.sequence[0];
console.log(`First test manifest type: ${firstManifest['@type']}`);

// To load an actual test input file, you'd typically iterate through the manifest
// and construct paths based on the 'input' property of each test entry.
// For example, if a test entry has 'input': 'compact-0001-in.jsonld'
const exampleInputPath = join(packageRoot, 'tests/compact-0001-in.jsonld');
const exampleInput = JSON.parse(readFileSync(exampleInputPath, 'utf8'));
console.log('Example test input data:', exampleInput);

view raw JSON →