{"id":25949,"library":"mocha-stylus-compiler","title":"mocha-stylus-compiler","description":"A Stylus compiler plugin for Mocha that allows requiring .styl files in tests, compiling them to CSS but ignoring the output (compiles to null). Version 1.0.1 is the latest and only stable release. It is a minimal tool for integrating Stylus preprocessing into Mocha test runs. Unlike alternative approaches (like using stylus directly or other Mocha compilers), this package specifically registers .styl files with Mocha's --compilers option, preventing parse errors when requiring Stylus files in tests. No updates since initial release; considered stable but unmaintained.","status":"maintenance","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/asbjornenge/mocha-stylus-compiler","tags":["javascript","mocha","mocha-compiler","stylus"],"install":[{"cmd":"npm install mocha-stylus-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add mocha-stylus-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add mocha-stylus-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is only used as a Mocha compiler via CLI flag, not imported directly in source code. However, if used programmatically with Mocha API, you would pass the function returned by require().","wrong":"import mochaStylus from 'mocha-stylus-compiler'","symbol":"default","correct":"require('mocha-stylus-compiler')"}],"quickstart":{"code":"// Install mocha and mocha-stylus-compiler\n// npm install --save-dev mocha mocha-stylus-compiler\n\n// Create a test file test/example.test.js\nconst assert = require('assert');\nconst styles = require('./styles.styl'); // This will compile to an empty object\n\ndescribe('Stylus', function() {\n  it('should compile without error', function() {\n    assert.equal(typeof styles, 'object');\n  });\n});\n\n// Run: npx mocha --compilers styl:mocha-stylus-compiler","lang":"javascript","description":"Shows how to set up and run Mocha tests that require .styl files using the Stylus compiler."},"warnings":[{"fix":"If you need to use the compiled CSS in tests, consider using a different approach (e.g., compile Stylus files separately and read the output).","message":"The package compiles Stylus to CSS but discards the output, so requiring a .styl file returns an empty object `{}`. This may be unexpected if you intend to actually use the compiled CSS.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For Mocha v8+, use `--require mocha-stylus-compiler/register` if available, or switch to a compiler that supports the new API. Alternatively, downgrade Mocha to v7 or earlier.","message":"Mocha v8+ deprecated the --compilers option in favor of --require with a custom compiler. The package may not work with newer Mocha versions.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Rename your files to .styl or modify the compiler registration to match your extension.","message":"The package only compiles .styl files with the extension `.styl`. If you use a different extension (e.g., .stylus), the compiler will not be applied.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install locally: `npm install --save-dev mocha-stylus-compiler` and use local Mocha: `npx mocha --compilers styl:mocha-stylus-compiler`","cause":"Package not installed, or not in node_modules when Mocha runs (often due to global Mocha installation).","error":"Error: Cannot find module 'mocha-stylus-compiler'"},{"fix":"Use a webpack loader for Stylus files (e.g., stylus-loader) instead of this package.","cause":"Webpack does not allow modifying require.extensions, which this package relies on. This package is intended for Node.js Mocha, not webpack.","error":"Error: require.extensions is not supported by webpack"},{"fix":"Install stylus: `npm install --save-dev stylus`","cause":"The package depends on `stylus` as a peer dependency, but it may not be installed.","error":"Error: Cannot find module 'stylus'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}