Test262 Test Suite Stream API

1.4.0 · maintenance · verified Tue Apr 21

test262-stream offers a Node.js API for programmatically traversing and consuming the Test262 JavaScript conformance test suite. It enables developers to stream individual test cases, their complete source code (including any 'includes' files), associated metadata, and copyright information. This library is particularly valuable for JavaScript engine developers, transpiler authors, or anyone constructing tools that require automated execution or analysis of Test262 tests. The current stable version is 1.4.0. Given its specialized function of parsing a specific external test suite, its release cadence is likely synchronized with updates or structural modifications within the Test262 repository itself, rather than frequent independent feature releases. Its primary differentiator lies in offering stream-based, granular access to Test262 content, abstracting away the complexities of file system traversal and frontmatter parsing, which distinguishes it from manual file reading or lower-level Test262 utilities.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes a `TestStream` to process a subset of the Test262 test suite, logging details of each test found.

import TestStream from 'test262-stream';
import path from 'path';

// Replace with your actual path to the Test262 repository
const test262Dir = process.env.TEST262_DIR || '/path/to/test262';

const stream = new TestStream(test262Dir, {
    includesDir: path.join(test262Dir, 'harness'),
    paths: ['test/built-ins/eval', 'test/language/statements/empty/S12.3_A1.js'],
    omitRuntime: true,
    acceptVersion: '2.0.0'
});

stream.on('data', function(test) {
    console.log(`File: ${test.file}`);
    console.log(`Scenario: ${test.scenario}`);
    // console.log(`Contents:\n${test.contents}`); // Uncomment for full contents
    // console.log(`Attributes: ${JSON.stringify(test.attrs, null, 2)}`);
    // console.log(`Copyright: ${test.copyright}`);
    // console.log(`Insertion Index: ${test.insertionIndex}`);
});

stream.on('end', function() {
    console.log('No further tests.');
});

stream.on('error', function(err) {
    console.error('Something went wrong:', err.message);
    process.exit(1);
});

view raw JSON →