Registry / testing / rdf-test-suite

rdf-test-suite

JSON →
library2.1.5jsnpmunverified

rdf-test-suite (current stable version 2.1.5) is a robust JavaScript/TypeScript command-line tool and library designed for executing W3C RDF and SPARQL test suites against any compatible JavaScript-based engine. It is actively maintained, with a development focus on broad test suite compatibility and modularity. Key differentiators include its support for a wide array of specifications such as SPARQL 1.0/1.1, RDF/XML, N-Triples, N-Quads, Turtle, TriG, JSON-LD (1.0/1.1), RDFa, Microdata, N3, and RDF-star/SPARQL-star, with a clear roadmap for expanding coverage. The tool itself functions as a runner, requiring users to provide their own JavaScript implementation of an RDF parser or SPARQL query engine that adheres to specific TypeScript interfaces (e.g., `IQueryEngine`, `IParser`) depending on the test suite being executed. It can output human-readable results to the console or machine-readable EARL reports for compliance tracking. Its modular architecture facilitates easy extension for new test cases or report formats.

npm install rdf-test-suite
INSTALL
IMPORT
SIG · RDF-TEST-SUITE
R
rdf-test-suite
testingjavascriptv2.1.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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.

TestSuiteRunner
import { TestSuiteRunner } from 'rdf-test-suite';
const TestSuiteRunner = require('rdf-test-suite');
For programmatic execution of test suites. CommonJS users should use `const { TestSuiteRunner } = require('rdf-test-suite');`
IQueryEngine
import type { IQueryEngine } from 'rdf-test-suite';
import { IQueryEngine } from 'rdf-test-suite';
Interface for implementing SPARQL query engines. Use 'import type' as it's a TypeScript interface, not a runtime value.
IParser
import type { IParser } from 'rdf-test-suite';
const IParser = require('rdf-test-suite').IParser;
Interface for implementing RDF syntax parsers. Use 'import type' for TypeScript type-only imports; cannot be `require()`d.

Demonstrates programmatic execution of a SPARQL 1.1 test suite against a dummy query engine, logging a summary of the test results.

import { TestSuiteRunner, type IQueryEngine } from 'rdf-test-suite'; import { AsyncIterator } from 'asynciterator'; // Make sure 'asynciterator' is installed // Define a minimal, non-functional SPARQL query engine for demonstration. // In a real scenario, this would be your actual SPARQL engine implementation. const dummyEngine: IQueryEngine = { async query(queryString: string, queryContext?: any): Promise<AsyncIterator<any>> { console.log(`[DummyEngine] Executing query (truncated): ${queryString.substring(0, 70)}...`); return new AsyncIterator(); // Returns an empty iterator, most tests will fail or be skipped. }, async update(updateString: string, updateContext?: any): Promise<void> { console.log(`[DummyEngine] Executing update (truncated): ${updateString.substring(0, 70)}...`); return Promise.resolve(); }, }; async function runExampleTestSuite() { const runner = new TestSuiteRunner(); const sparql11ManifestUrl = 'https://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl'; console.log(`Starting SPARQL 1.1 test suite run against dummy engine...`); console.log(`Manifest: ${sparql11ManifestUrl}`); // Run the test suite and get an async iterator of results. const results = await runner.runTestSuite(dummyEngine, sparql11ManifestUrl, { verbose: false, // Set to true for more detailed console output exitOnFail: false, // Continue even if tests fail }); // Iterate over results and summarize let passed = 0; let failed = 0; let skipped = 0; for await (const result of results) { if (result.type === 'test') { if (result.skipped) { skipped++; } else if (result.error) { failed++; } else { passed++; } } } console.log('\n--- Summary ---'); console.log(`Tests Passed: ${passed}`); console.log(`Tests Failed: ${failed}`); console.log(`Tests Skipped: ${skipped}`); console.log('Note: Most tests are expected to fail or be skipped with a dummy engine.'); } runExampleTestSuite().catch(console.error);
rdf-test-suite.js --version
Debug
Known issues
gotchaThe `rdf-test-suite` package acts as a test runner and does not include an RDF parser or SPARQL query engine itself. You must provide your own JavaScript implementation of the required engine.
fix
Implement the `IQueryEngine` (for SPARQL) or `IParser` (for RDF syntax) interface and pass an instance of your engine to the `TestSuiteRunner`.
affects: >=1.0.0
gotchaThe specific interface (e.g., `IQueryEngine` or `IParser`) that your engine must implement depends on the type of test suite manifest being executed. An engine for SPARQL tests will not work for RDF syntax tests.
fix
Consult the `rdf-test-suite` documentation and TypeScript definitions (e.g., `lib/testcase/sparql/IQueryEngine.ts`, `lib/testcase/rdfsyntax/IParser.ts`) to understand the exact interface required for your chosen test suite.
affects: >=1.0.0
gotchaNot all W3C RDF and SPARQL test suites are currently supported. If a specific test suite is not listed in the documentation, it might not be executable out-of-the-box.
fix
Verify that the specific W3C test suite you intend to run is listed as 'supported' in the documentation. The package is modular, allowing for custom extensions for unsupported suites.
affects: >=1.0.0
Errors
Common errors & fixes
Error: No valid test cases could be found for the given manifest.
The provided manifest URL is incorrect, inaccessible, or points to an unsupported test suite type/format.
fix
Verify the manifest URL is correct and points to a supported W3C test suite. Ensure network access to the manifest and check for any proxies or firewalls blocking access.
TypeError: The provided engine does not implement the required interface for this test suite.
The JavaScript/TypeScript file supplied as the engine argument (either via CLI or programmatically) does not properly export an object that implements the expected interface for the test suite type.
fix
Ensure your engine implementation fully adheres to the TypeScript interface required by the specific test suite (e.g., `IQueryEngine` for SPARQL tests or `IParser` for RDF syntax tests), including all required methods and their signatures.
Upgrade
Version history
2.1.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
rdf-test-suite — npm install rdf-test-suite · libregistry