Registry / testing / mocha-traceur

mocha-traceur

JSON →
library2.1.0jsnpmunverified

A Mocha plugin that compiles JavaScript files through the Traceur transpiler, enabling ES6 (ES2015) features for test files. Version 2.1.0 is the current stable release, depending on 'traceur-runner' for stack traces and optional dependency compilation. It operates via Mocha's --compilers flag. Key differentiator vs alternatives like babel-register: focused solely on Traceur, with no dependency compilation by default, making it lightweight but restrictive. The package is maintained infrequently; latest release 2.1.0 is several years old. Does not bundle Traceur itself, requiring a separate install.

npm install mocha-traceur
INSTALL
IMPORT
SIG · MOCHA-TRACEUR
M
mocha-traceur
testingjavascriptv2.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

mocha-traceur (plugin)
mocha --compilers js:mocha-traceur my_test_dir/*.js
require('mocha-traceur')
Not a module import; used solely via Mocha's CLI --compilers flag. No programmatic usage.

Setup and run Mocha tests with Traceur transpilation via --compilers flag, demonstrating ES6 arrow functions and template literals.

// Install dependencies npm install --save-dev mocha mocha-traceur traceur // Create a test file 'test/test.js' with ES6 features import { strictEqual } from 'assert'; const greet = (name) => `Hello, ${name}!`; describe('greet', () => { it('should greet a person', () => { strictEqual(greet('World'), 'Hello, World!'); }); }); // Run tests from command line mocha --compilers js:mocha-traceur test/*.js
Debug
Known issues
breakingDependencies under node_modules are NOT compiled with Traceur. If your code imports from an ES6-only package not transpiled, it will fail at runtime.
fix
Use only transpiled dependencies, or switch to babel-register which can transpile node_modules via ignore patterns.
affects: >=2.0.0
deprecatedTraceur Compiler is no longer actively maintained. Prefer Babel or TypeScript for ES6+ transpilation.
fix
Migrate to a modern transpiler like Babel with @babel/register.
affects: >=1.0.0
gotchaThe package does not include Traceur itself. You must install traceur separately, or use traceur-runner (optional) to add stack trace support.
fix
Run: npm install --save-dev traceur or traceur-runner
affects: >=1.0.0
breakingIn v2, dependencies are no longer compiled. If you relied on dependency transpilation in v1, tests may break after upgrading.
fix
Ensure all dependencies are pre-transpiled, or pin to v1.x if dependency transpilation is required.
affects: >=2.0.0 <3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'traceur'
The package does not bundle Traceur; it must be installed separately.
fix
Run: npm install --save-dev traceur
Error: Unexpected token import
Mocha does not natively support ES6 modules. The --compilers flag may not be applied correctly, or the plugin isn't loading.
fix
Use command: mocha --compilers js:mocha-traceur test/*.js (ensure the flag uses the correct path to mocha-traceur).
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
Traceur may not be transpiling because the file is not passed through the plugin (e.g., due to incorrect file extension or missing --compilers flag).
fix
Ensure --compilers is set correctly and that your test files match the pattern (e.g., .js). Add 'use strict' if needed.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
traceur-runneroptionalProvides stack-trace rewriting and optional dependency compilation with Traceur.
Agent activity
2 hits · last 30 days
node
2
Resources
mocha-traceur — npm install mocha-traceur · libregistry