MOCHA(1)
π MOCHA π
okay bestie, sit DOWN, because we're talking about mocha β the simple, flexible, fun test framework (that's literally its whole brand, and honestly? it ate). this is the MOCHA(1) page, User Commands territory, and i'm gonna walk you through every single flag like we're texting at 2am. no cap, every option is coming with us. π
β¨ NAME β¨
mocha β simple, flexible, fun test framework π
πΈ DESCRIPTION πΈ
so the whole vibe is:
mocha [spec..]
Run tests with Mocha. that's the assignment. that's it. π
π¦ Commands π¦
mocha [spec..]β Run tests with Mocha. this one is the [default], the main character, the one everybody shows up for.mocha inspect [spec..]β Run tests with Mocha, but in inspector mode. (yes it's also listed as[default]up there with the plain form β the manpage says so, we don't argue with the manpage π)mocha init <path>β create a client-side Mocha setup at<path>. new folder, new setup, new era. β¨
π Rules & Behavior π
--allow-uncaughtβ allow uncaught errors to propagate. let 'em run loose. [boolean]-A,--async-onlyβ every test has to use a callback (async) or return a Promise. no sneaky sync tests allowed, bestie. [boolean]-b,--bailβ abort ("bail") after the first test failure. one L and we're OUT. [boolean]--check-leaksβ check for global variable leaks. who left that variable lying around?? π [boolean]--delayβ delay the initial execution of the root suite. a lil dramatic pause. [boolean]--dry-runβ report tests without actually executing them. window shopping, but for tests. [boolean]--exitβ Force Mocha to quit after tests complete. bye, we're leaving. [boolean]--pass-on-failing-test-suiteβ Not fail test run if tests were failed. [boolean] [default:false]--fail-hook-affected-testsβ Report tests as failed when affected by hook failures (before/beforeEach). yep, if the hook fumbled it, the tests feel it too. [boolean]--fail-zeroβ Fail test run if no test(s) encountered. zero tests = zero chill. [boolean]--forbid-onlyβ Fail if exclusive test(s) encountered. noonly-ing your way through, diva. [boolean]--forbid-pendingβ Fail if pending test(s) encountered. no ghost tests. [boolean]--global,--globalsβ List of allowed global variables. [array]-j,--jobsβ Number of concurrent jobs for--parallel; use1to run in serial. [number] [default: (number of CPU cores - 1)] β so if your laptop has 9 cores, congrats, you get 8. π€-p,--parallelβ Run tests in parallel. multitasking queen behavior. [boolean]--posix-exit-codesβ Use POSIX and UNIX shell exit codes as Mocha's return value. [boolean]--retriesβ Retry failed tests this many times. we try again, bestie, we always try again. [number]-s,--slowβ Specify "slow" test threshold (in milliseconds). [string] [default:75]-t,--timeout,--timeoutsβ Specify test timeout threshold (in milliseconds). [string] [default:2000]-u,--uiβ Specify user interface. [string] [default:"bdd"]
π Reporting & Output π
-c,--color,--colorsβ Force-enable color output. yes we're doing rainbows, deal. π¨ [boolean]--diffβ Show diff on failure. [boolean] [default:true]--full-traceβ Display full stack traces. the WHOLE story, no skimming. [boolean]--inline-diffsβ Display actual/expected differences inline within each string. [boolean]-R,--reporterβ Specify reporter to use. [string] [default:"spec"]-O,--reporter-option,--reporter-optionsβ Reporter-specific options, in the format<k=v,[k1=v1,..]>. [array]
π§ Configuration π§
--configβ Path to config file. [string] [default: (nearest rc file)]-n,--node-optionβ Node or V8 option (no leading"--"). [array]--packageβ Path topackage.jsonfor config. [string]
π File Handling π
--extensionβ File extension(s) to load. [array] [default:["js","cjs","mjs"]]--fileβ Specify file(s) to be loaded prior to root suite execution. [array] [default: (none)]--ignore,--excludeβ Ignore file(s) or glob pattern(s). [array] [default: (none)]--recursiveβ Look for tests in subdirectories. dig deep. [boolean]-r,--requireβ Require module. [array] [default: (none)]-S,--sortβ Sort test files. alphabetize besties. [boolean]-w,--watchβ Watch files in the current working directory for changes. π [boolean]--watch-filesβ List of paths or globs to watch. [array]--watch-ignoreβ List of paths or globs to exclude from watching. [array] [default:["node_modules",".git"]]
π Test Filters π
-f,--fgrepβ Only run tests containing this string. [string]-g,--grepβ Only run tests matching this string or regexp. [string]-i,--invertβ Inverts--grepand--fgrepmatches. you said what you said, now we do the opposite. [boolean]
β Positional Arguments β
specβ One or more files, directories, or globs to test. [array] [default:["test"]]
π₯ Other Options π₯
-h,--helpβ Show usage information & exit. [boolean]-V,--versionβ Show version number & exit. [boolean]--list-interfacesβ List built-in user interfaces & exit. [boolean]--list-reportersβ List built-in reporters & exit. [boolean]
π Mocha Resources π
go be nosy, there's lore:
- Chat:
https://discord.gg/KeDn2uXhER - GitHub:
https://github.com/mochajs/mocha.git - Docs:
https://mochajs.org/
and that's the whole page, bestie. you now know mocha better than most people know their own phone passcode. iykyk. π«Ά
~ cute sign-off ~ this was mocha version 11.8.0, dated August 2026, and yeah, it lives at MOCHA(1). mwah. π
β¨πΈ
π¦ where this page comes from
- ubuntu stonking: mocha 11.8.0+ds1+~cs36.4.12-2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms