{"id":15397,"library":"test262-stream","title":"Test262 Test Suite Stream API","description":"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.","status":"maintenance","version":"1.4.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install test262-stream","lang":"bash","label":"npm"},{"cmd":"yarn add test262-stream","lang":"bash","label":"yarn"},{"cmd":"pnpm add test262-stream","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"const TestStream = require('test262-stream');","symbol":"TestStream","correct":"import TestStream from 'test262-stream';"},{"note":"The primary export is a class named `TestStream`. There is no named export for `Test262Stream`.","symbol":"Test262Stream","correct":"import TestStream from 'test262-stream';"},{"note":"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.","wrong":"for await (const test of stream) { ... }","symbol":"stream events","correct":"stream.on('data', function(test) { ... });\nstream.on('end', function() { ... });\nstream.on('error', function(err) { ... });"}],"quickstart":{"code":"import TestStream from 'test262-stream';\nimport path from 'path';\n\n// Replace with your actual path to the Test262 repository\nconst test262Dir = process.env.TEST262_DIR || '/path/to/test262';\n\nconst stream = new TestStream(test262Dir, {\n    includesDir: path.join(test262Dir, 'harness'),\n    paths: ['test/built-ins/eval', 'test/language/statements/empty/S12.3_A1.js'],\n    omitRuntime: true,\n    acceptVersion: '2.0.0'\n});\n\nstream.on('data', function(test) {\n    console.log(`File: ${test.file}`);\n    console.log(`Scenario: ${test.scenario}`);\n    // console.log(`Contents:\\n${test.contents}`); // Uncomment for full contents\n    // console.log(`Attributes: ${JSON.stringify(test.attrs, null, 2)}`);\n    // console.log(`Copyright: ${test.copyright}`);\n    // console.log(`Insertion Index: ${test.insertionIndex}`);\n});\n\nstream.on('end', function() {\n    console.log('No further tests.');\n});\n\nstream.on('error', function(err) {\n    console.error('Something went wrong:', err.message);\n    process.exit(1);\n});","lang":"javascript","description":"This quickstart initializes a `TestStream` to process a subset of the Test262 test suite, logging details of each test found."},"warnings":[{"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.","message":"Using 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Verify that the `test262Dir` argument points to the correct absolute or relative path of your Test262 repository clone.","message":"The `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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set `omitRuntime: false` if you intend to execute `test.contents` directly. Understand the implications based on your use case for the test content.","message":"Setting `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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `import TestStream from 'test262-stream';` in ESM modules, or ensure your project is configured for CommonJS if sticking with `require`.","message":"The usage example shows `var TestStream = require('test262-stream');`. While functional in CommonJS environments, modern Node.js development strongly recommends ESM `import` syntax.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"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.","cause":"The `test262Dir` provided to the `TestStream` constructor is not the root of a valid Test262 repository clone, or the 'test' subdirectory is missing/misplaced.","error":"Error: provided Test262 directory does not contain 'test' subdirectory"},{"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.","cause":"The Test262 repository you are streaming has a version that is not officially supported by this `test262-stream` library version.","error":"Error: Unsupported Test262 version"}],"ecosystem":"npm"}