Registry / testing / test262-stream

test262-stream

JSON →
library1.4.0jsnpmunverified

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.

npm install test262-stream
INSTALL
IMPORT
SIG · TEST262-STREAM
T
test262-stream
testingjavascriptv1.4.0
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.

TestStream
import TestStream from 'test262-stream';
const TestStream = require('test262-stream');
The documentation uses CommonJS `require`, but ESM `import` is the modern standard. Both are likely supported if running in an environment that handles CJS interoperability.
Test262Stream
import TestStream from 'test262-stream';
The primary export is a class named `TestStream`. There is no named export for `Test262Stream`.
stream events
stream.on('data', function(test) { ... }); stream.on('end', function() { ... }); stream.on('error', function(err) { ... });
for await (const test of stream) { ... }
The library uses Node.js `EventEmitter` pattern for streams. While async iterators might work for readable streams, the library's primary documented usage is event-based.

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); });
Debug
Known issues
gotchaUsing the `acceptVersion` option with an outdated or incorrect version can lead to the stream emitting invalid tests that may not accurately reflect the Test262 specification. It's generally safer to update the library to ensure compatibility.
fix
Omit `acceptVersion` to rely on the library's default supported version, or ensure the provided version matches the actual Test262 repository version you are using. Consider updating the `test262-stream` library itself.
affects: >=1.0.0
gotchaThe `test262Dir` path must point to the root directory of a cloned Test262 repository. An incorrect path will result in errors as the library won't be able to locate tests or harness files.
fix
Verify that the `test262Dir` argument points to the correct absolute or relative path of your Test262 repository clone.
affects: >=1.0.0
gotchaSetting `omitRuntime: true` will prevent the insertion of necessary execution code (like assertion functions and 'include' files) into `test.contents`. This is useful for static analysis but will make the `contents` property unsuitable for direct execution.
fix
Set `omitRuntime: false` if you intend to execute `test.contents` directly. Understand the implications based on your use case for the test content.
affects: >=1.0.0
deprecatedThe usage example shows `var TestStream = require('test262-stream');`. While functional in CommonJS environments, modern Node.js development strongly recommends ESM `import` syntax.
fix
Use `import TestStream from 'test262-stream';` in ESM modules, or ensure your project is configured for CommonJS if sticking with `require`.
affects: >=1.0.0
Errors
Common errors & fixes
Error: provided Test262 directory does not contain 'test' subdirectory
The `test262Dir` provided to the `TestStream` constructor is not the root of a valid Test262 repository clone, or the 'test' subdirectory is missing/misplaced.
fix
Ensure `test262Dir` points to the exact root of your Test262 repository clone, which typically contains 'test/', 'harness/', and other standard Test262 directories. Double-check the path for typos.
Error: Unsupported Test262 version
The Test262 repository you are streaming has a version that is not officially supported by this `test262-stream` library version.
fix
Update your `test262-stream` package to the latest version, or, as a temporary workaround (with caution), provide the `acceptVersion` option with the version string of your Test262 clone. However, updating the library is the recommended approach for compatibility.
Upgrade
Version history
1.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
test262-stream — npm install test262-stream · libregistry