Registry / testing / test262-parser-runner

test262-parser-runner

JSON →
library0.5.0jsnpmunverified

The `test262-parser-runner` is a utility designed to execute the official ECMAScript Test Suite (Test262) against any given JavaScript parser. Currently at version 0.5.0, it targets early-stage development and parser validation. While it doesn't specify a fixed release cadence, its versioning suggests ongoing development with potentially frequent updates. A key differentiator is its robust mechanism for managing test outcomes: it supports a `skip` filter function to completely ignore tests (e.g., for unimplemented features) and a `whitelist` array for tests expected to fail temporarily but eventually pass. This allows parser developers to precisely control which tests contribute to their pass/fail metrics. The project distinguishes itself by building upon a previously MIT-licensed test runner while distributing its own code under the GNU Affero General Public License v3.0, a significant detail for downstream users.

npm install test262-parser-runner
INSTALL
IMPORT
SIG · TEST262-PARSER-RUN
T
test262-parser-runner
testingjavascriptv0.5.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

run
✓ import run from 'test262-parser-runner';
✗ const { run } = require('test262-parser-runner');
The `require` example from the README suggests a default export for the main `run` function.
run
✓ const run = require('test262-parser-runner');
✗ import { run } from 'test262-parser-runner';
CommonJS `require` is explicitly shown in the official usage examples.
parse
✓ import { parse } from 'acorn';
✗ const parse = require('acorn').parse;
`acorn` is commonly imported via named exports in modern JavaScript, though CommonJS `.parse` also works.

This quickstart demonstrates how to run the Test262 suite against the Acorn parser, configuring custom skip and whitelist rules, and specifying the Test262 repository path.

import run from 'test262-parser-runner'; import { parse } from 'acorn'; import path from 'path'; // Ensure you have test262 cloned locally, e.g., git clone https://github.com/tc39/test262 const test262Dir = process.env.TEST262_DIR ?? path.resolve(__dirname, 'path/to/your/test262/repo'); if (!test262Dir) { console.error('Please set the TEST262_DIR environment variable or update the quickstart code with the path to your cloned test262 repository.'); process.exit(1); } run( (content, { sourceType }) => parse(content, { sourceType, ecmaVersion: 2020 }), // Assuming a modern ecmaVersion { skip: test => false, // No tests are skipped by default whitelist: [ // Example: 'test/language/expressions/arrow-function/syntax-error-no-newline.js' ], testsDirectory: test262Dir, // Specify the path to your Test262 clone // Other options like 'limit', 'reporter' can be added here } ).then(results => { console.log('Test run complete:', results); if (results.failures.length > 0) { console.error(`Found ${results.failures.length} failures.`); // Optionally process or log detailed failures } else { console.log('All whitelisted tests passed successfully.'); } }).catch(error => { console.error('An error occurred during test run:', error); });
test262-parser-runner --version
Debug
Known issues
gotchaThe `test262-parser-runner` package itself is licensed under the GNU Affero General Public License v3.0, despite being based on an MIT-licensed component. This has significant implications for derivative works and distribution.
fix
Review the AGPLv3.0 license terms carefully to understand your obligations before integrating into your project, especially if distributing commercially or as part of a proprietary system.
affects: >=0.1.0
gotchaThe package version 0.5.0 indicates it is still in an early development stage (pre-1.0.0). While API stability is generally a goal, breaking changes might occur in minor versions before a stable 1.0.0 release.
fix
Pin exact versions (e.g., `"test262-parser-runner": "0.5.0"`) or use a tilde range (`~0.5.0`) to avoid unexpected updates. Regularly check the project's changelog for breaking changes.
affects: >=0.1.0
gotchaBy default, `test262-parser-runner` might use a bundled version of the Test262 suite if `testsDirectory` is not specified. This bundled version may be outdated, leading to tests that don't reflect the latest ECMAScript specification.
fix
Always provide an explicit `testsDirectory` option pointing to a fresh, cloned copy of the official `tc39/test262` GitHub repository to ensure you are testing against the most current suite.
affects: >=0.1.0
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, stat '/path/to/test262'
The `testsDirectory` option points to a non-existent or inaccessible path for the Test262 repository.
fix
Ensure the path provided to `testsDirectory` is correct and accessible. Clone the `tc39/test262` repository locally and point the option to its root directory.
TypeError: parse is not a function
The parser function provided to `run` is either undefined or not a callable function, or its arguments are not being destructured correctly.
fix
Verify that your parser (e.g., `acorn.parse`) is correctly imported and that the wrapper function passed to `run` correctly calls it with `content` and `sourceType`.
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies
acornoptionalCommonly used as the parser target in examples and real-world usage.
test262optionalProvides the actual ECMAScript test suite files. While a bundled version is default, direct dependency allows for control.
Agent activity
8 hits · last 30 days
node
8
Resources