Meta tags:
Headings (most frequently used words):
root, tests, name, hook, hooks, file, global, option, parallel, directory, reporter, plugins, browser, glob, to, test, fixtures, node, mocha, options, in, mode, use, ms, about, level, only, js, reporters, configuration, path, watch, inspect, with, multiple, code, require, are, ignore, function, testing, migrating, is, asynchronous, module, count, that, config, async, bail, not, when, suite, run, the, limitations, json, features, diffs, duration, flags, party, regexp, grep, plugin, string, forbid, files, exclusive, pending, third, support, no, limited, troubleshooting, api, effort, for, reporting, order, modules, from, types, cli, enable, source, maps, v8, disallowed, best, slightly, differ, worker, non, deterministic, variability, caveats, export, es, extending, strip, list, progress, jetbrains, textmate, format, stream, min, doc, tap, markdown, xunit, html, current, merging, priorities, ignoring, locations, custom, landing, nyan, commonjs, sidebar, ids, defining, vs, available, single, can, specific, library, emacs, matrix, setup, teardown, wallaby, bdd, tdd, exports, qunit, spec, dot, sponsors, jobs, esm, usage, fixture, decision, tree, wizard, thing, interfaces, native, running, command, configuring, error, codes, editor, examples, more, information, serial, line, timeouts, promises, detects, table, of, contents, installation, getting, started, cycle, overview, calls, generating, done, assertions, synchronous, arrow, functions, inclusive, retry, dynamically, working, using, ext, full, trace, inline, backers, opts, package, extension, exclude, colors, recursive, sort, fgrep, invert, brk, diff, await, dry, describing, delayed, allow, uncaught, check, leaks, compilers, exit, color, fail, zero, variable, retries, slow, timeout, ui, context,
Text of the page (most frequently used words):
the (369), #test (246), #mocha (200), #function (163), #tests (160), this (143), and (136), for (130), #will (111), use (103), #hooks (93), you (93), not (91), with (85), run (83), #file (80), #should (73), root (72), global (69), can (69), are (66), your (64), describe (63), #reporter (61), when (57), files (57), only (54), before (51), parallel (51), done (50), suite (50), #require (49), all (48), hook (47), node (45), using (45), default (44), option (43), return (43), that (42), example (42), after (41), mode (41), new (40), array (40), beforeeach (37), setup (37), may (37), any (36), fixtures (34), indexof (34), which (33), async (32), running (30), options (30), json (30), code (29), spec (28), boolean (28), timeout (28), assert (28), skip (27), args (27), each (26), list (26), server (25), via (25), present (25), also (25), expected (23), from (23), configuration (23), interface (23), output (23), module (22), process (22), string (22), watch (22), package (22), reporters (22), user (21), see (21), directory (21), value (21), support (21), but (21), mjs (21), other (21), script (20), const (20), extension (20), multiple (20), specify (20), alias (19), plugins (18), slow (18), specified (18), used (18), object (18), config (18), have (18), error (18), grep (18), await (18), browser (18), mocharc (17), some (17), above (17), once (17), cases (16), exit (16), bdd (16), worker (16), does (16), pending (16), more (16), path (16), suites (16), work (15), true (15), flags (15), context (15), note (15), given (15), these (15), following (15), html (14), flag (14), assertion (14), runs (14), name (14), add (14), one (14), check (14), need (14), times (14), fixture (14), instead (14), level (14), loaded (13), exclusive (13), promise (13), command (13), custom (13), export (13), here (13), exports (13), ignore (13), equal (13), still (13), examples (12), defined (12), every (12), find (12), number (12), its (12), was (12), them (12), callback (12), fail (12), set (12), mochahooks (12), port (12), they (12), api (12), supports (11), get (11), err (11), must (11), timeouts (11), same (11), make (11), then (11), aftereach (11), want (11), glob (11), case (11), first (11), plugin (11), save (11), like (11), etc (11), within (10), matching (10), available (10), assertions (10), color (10), environment (10), users (10), diff (10), way (10), library (10), order (10), time (10), cjs (10), now (10), modules (10), var (10), specific (10), unless (10), property (10), bail (10), disable (9), foo (9), recursive (9), double (9), console (9), such (9), length (9), pass (9), asynchronous (9), results (9), into (9), something (9), found (9), otherwise (9), serial (9), behavior (9), uncaught (9), teardown (9), github (8), execution (8), has (8), jobs (8), fgrep (8), npm (8), tdd (8), don (8), sort (8), useful (8), information (8), style (8), index (8), javascript (8), containing (8), where (8), retry (8), retries (8), cannot (8), than (8), skipped (8), line (8), inspect (8), editor (8), app (8), working (8), adds (8), create (8), correctly (8), interfaces (8), well (8), updated (8), res (8), type (8), equivalent (8), globs (8), without (8), testing (8), there (7), failures (7), encountered (7), current (7), diffs (7), failure (7), show (7), simple (7), top (7), trademarks (7), doc (7), delay (7), forbid (7), delimited (7), newer (7), esm (7), bar (7), allows (7), expect (7), built (7), uses (7), duration (7), comma (7), directly (7), markdown (7), connection (7), settimeout (7), install (7), count (7), single (7), both (7), src (7), failed (7), recommended (7), executed (7), itself (7), party (7), threshold (6), import (6), progress (6), env (6), while (6), enable (6), about (6), provides (6), regexp (6), third (6), even (6), reporting (6), child (6), git (6), log (6), foundation (6), openjs (6), executes (6), pool (6), abort (6), resolve (6), https (6), stop (6), com (6), executing (6), define (6), project (6), always (6), would (6), share (6), take (6), access (6), section (6), help (6), below (6), leaks (6), many (6), less (6), own (6), outputs (6), feature (6), arr (6), throw (6), passing (6), their (6), variable (6), ensure (6), best (6), documentation (6), complete (6), either (6), allow (6), our (6), title (5), end (5), look (5), tap (5), commonjs (5), load (5), write (5), required (5), just (5), chai (5), docs (5), xunit (5), loki (5), job (5), landing (5), stream (5), else (5), calling (5), report (5), tobi (5), execute (5), jane (5), final (5), put (5), node_modules (5), maps (5), further (5), nodejs (5), called (5), contains (5), supported (5), incompatible (5), milliseconds (5), changes (5), warning (5), exceptions (5), exception (5), entire (5), passed (5), considered (5), force (5), description (5), non (5), applicable (5), libraries (5), resources (5), source (5), result (5), connect (5), cause (5), strings (5), accepts (5), exclude (5), mutually (5), version (5), inline (5), qunit (4), processes (4), synchronous (4), shown (4), block (4), argument (4), could (4), lambdas (4), native (4), respond (4), test_port (4), pre (4), dynamically (4), globals (4), means (4), causes (4), anything (4), variables (4), special (4), written (4), practice (4), eventually (4), quotes (4), stack (4), read (4), call (4), traces (4), system (4), executable (4), yui (4), removed (4), out (4), view (4), paths (4), disallowed (4), foreach (4), marked (4), loads (4), between (4), please (4), around (4), valid (4), what (4), nyan (4), having (4), registered (4), detects (4), functions (4), known (4), nor (4), types (4), nothing (4), subdirectories (4), trademark (4), policy (4), won (4), generating (4), syntax (4), however (4), beforeall (4), curr (4), strictequal (4), large (4), great (4), full (4), allowed (4), named (4), summary (4), 2000 (4), performance (4), class (4), display (4), handle (4), body (4), mochaglobalsetup (4), database (4), try (4), testadd (4), usage (4), dot (4), looks (4), min (4), because (4), enabled (4), directories (3), explicitly (3), debugging (3), taking (3), nested (3), skipping (3), yellow (3), testcase (3), disabled (3), leading (3), colors (3), compilers (3), red (3), watched (3), defaulting (3), been (3), reported (3), babel (3), details (3), characters (3), defaults (3), scope (3), suppress (3), correct (3), extensions (3), actual (3), avoid (3), rerun (3), particularly (3), longer (3), properties (3), mochaglobalteardown (3), provide (3), startsomeserver (3), none (3), generate (3), cores (3), cpu (3), play (3), rules (3), memory (3), reason (3), applied (3), 500ms (3), getting (3), change (3), appropriate (3), tip (3), returning (3), perform (3), register (3), outside (3), usually (3), move (3), cleanup (3), afterall (3), shut (3), contain (3), down (3), callbacks (3), requires (3), build (3), stopped (3), another (3), choose (3), values (3), match (3), half (3), certain (3), long (3), false (3), tasks (3), anonymous (3), important (3), aware (3), enforce (3), rule (3), previous (3), yes (3), windows (3), two (3), plain (3), started (3), individual (3), depending (3), across (3), main (3), very (3), instance (3), wizard (3), decide (3), workarounds (3), issue (3), clean (3), method (3), inclusive (3), appending (3), unpkg (3), extensible (3), attempt (3), promises (3), possible (3), open (3), wiki (3), cli (3), checkleaks (3), roothooks (3), arrow (3), mochajs (3), looking (3), head (3), content (3), meta (3), loading (3), clear (3), records (3), regular (3), often (3), setimmediate (3), how (3), yaml (3), reference (3), enables (3), parameter (3), unsupported (3), textmate (3), thrown (3), throws (3), codes (3), scripts (3), jetbrains (3), maximum (3), compatibility (3), superagent (3), bash (3), installed (3), step (3), features (3), fun (3), vary (3), format (3), calls (3), sidebar (3), auto (3), yml (3), related (3), outputting (3), start (3), flexible (3), works (3), occur (3), errors (3), terminal (3), suppose (3), names (2), internal (2), launch (2), effectively (2), modes (2), begin (2), repeats (2), prints (2), epilog (2), configure (2), become (2), gives (2), 500 (2), defining (2), unique (2), registers (2), workers (2), bob (2), versions (2), 3rd (2), helpful (2), queue (2), 3000 (2), runtime (2), discouraged (2), launched (2), most (2), include (2), 300 (2), next (2), debugger (2), three (2), better (2), easily (2), jsonc (2), search (2), becomes (2), bin (2), migrating (2), especially (2), last (2), likewise (2), ignoring (2), location (2), exists (2), determine (2), sum (2), lead (2), installation (2), inspector (2), debug (2), highlighted (2), dev (2), returns (2), brk (2), based (2), conditionally (2), inverse (2), priority (2), invert (2), groupb (2), bootstrap_node (2), exceeding (2), groupa (2), real (2), arguments (2), effect (2), unhandled (2), strip (2), prior (2), those (2), steps (2), though (2), potential (2), associated (2), noted (2), spawn (2), benefit (2), handy (2), appear (2), properly (2), consuming (2), repeat (2), significant (2), dry (2), things (2), suggested (2), being (2), reports (2), fix (2), bundle (2), event (2), likely (2), trace (2), globally (2), finds (2), temporarily (2), falsy (2), subprocesses (2), hanging (2), completed (2), writing (2), happens (2), invalid (2), hang (2), depend (2), reduce (2), accurate (2), bigco (2), receives (2), coverage (2), 8192 (2), greater (2), keep (2), creates (2), expression (2), cycle (2), continuous (2), leak (2), emacs (2), shells (2), globstar (2), ides (2), fake (2), buffered (2), nature (2), know (2), zero (2), remove (2), themselves (2), table (2), wallaby (2), corresponding (2), intellij (2), message (2), limited (2), implications (2), timing (2), propagate (2), webstorm (2), idea (2), overview (2), merging (2), similar (2), state (2), width (2), initial (2), typescript (2), good (2), under (2), blocking (2), harnesses (2), tree (2), making (2), might (2), affected (2), namedfun (2), v10 (2), decision (2), finally (2), wish (2), let (2), infinite (2), init (2), hierarchical (2), accept (2), div (2), css (2), license (2), manner (2), 1000 (2), prev (2), until (2), wait (2), together (2), imply (2), easier (2), loops (2), repository (2), designed (2), strict (2), msg (2), expr (2), rejections (2), whatever (2), matches (2), words (2), failing (2), coloring (2), explicit (2), particular (2), readable (2), regardless (2), difference (2), adding (2), were (2), adjust (2), alternatively (2), limitations (2), suitesetup (2), thereof (2), xml (2), selenium (2), supply (2), much (2), delayed (2), nearest (2), filename (2), control (2), thing (2), anywhere (2), browsers (2), problems (2), prevent (2), generally (2), watching (2), latter (2), separate (2), v14 (2), highlight (2), functionality (2), cont (2), discord (2), lcov (2), neither (2), constructor (2), socket (2), starting (2), matrix (2), migrate (2), luna (2), alternative (2), configuring (2), tools (2), framework (2), typical (2), ignored (2), breaking (2), operations (2), provided (2), compatible (2), added (2), org (2), opening (2), mylib (2), setting (2), shortcut (2), override (2), truncated, 99999999, rich, guide, team, discovers, validates, watcher, displayed, ignores, highlights, aren, sponsors, marketing, coffee, async_hooks, wtfnode, suppressed, suffix, invoking, needed, transpiler, human, arbitrary, contents, conform, unusual, obvious, logo, mapping, therein, stops, update, children, ideas, implied, company, messes, too, leaving, relative, highlighting, whitelist, manager, comparing, exposes, deliberately, foobar, including, standards, bundled, map, hosted, ttys, barbar, conjunction, seconds, disables, omitted, active, wildcards, loop, therefore, optionally, durations, amount, bound, 9ms, mkdir, backer, favorite, ask, serially, detection, allowing, dependency, npmjs, tags, backers, back, lets, dsls, begins, interpret, development, maxdiffsize, specifies, outline, donation, monthly, flow, mid, inverts, problem, painful, parameterize, omit, bind, lexically, aka, closure, produce, specs, arises, refactor, expressions, right, straightforward, preconditions, interspersed, describing, supplied, pinpoint, optional, invoked, achieve, dummy, click, automatically, populate, testfile, documenting, self, unexpected, toolkit, causing, subclass, apis, alternately, promised, 5000, fluent, continue, mistake, collect, data, antipattern, dynamic, inside, handler, overspecified, resolution, older, responds, parameterized, seen, 75ms, confusion, outer, blocks, slice, precedence, precommit, integration, mean, really, usages, contrast, instructions, inner, commit, needs, detected, beforehand, commenting, placed, mindful, invoke, structure, tell, visualization, concat, statement, frameworks, attach, behaving, sync, isdisplayed, succeed, http, www, mechanism, preferred, yahoo, webdriver, chain, subset, overwrites, nexttick, iife, someone, included, marking, exclusivity, functional, mocked, stubbed, unit, throughout, image, easiest, asserting, explanation, leaked, acceptable, jquery, immediately, encounters, registering, meaning, compliant, difficult, track, quick, trap, typically, bootstraps, crash, commands, client, side, quit, concurrent, necessarily, upgrade, errant, invisible, members, made, ends, previously, inherits, parent, manifests, listening, runaway, never, validation, through, fulfilled, setinterval, finished, indicative, ultimately, dirty, negative, positive, differences, depicted, inherited, enough, sandwich, twice, give, 608, five, minutes, 187, accidental, 300000, tweak, startup, 6ms, normal, fast, green, levels, catching, 250, chat, handling, buffer, pattern, filters, onto, positional, holds, caveat, makes, kedn2uxher, actually, saw, assertionerror, silently, returned, enabletimeouts, again, 2500, completes, remain, harder, thu, limit, off, utf, charset, lang, doctype, onload, release, builds, mocks, libs, hold, switch, scale, testdouble, rewire, rewiremock, proxyquire, ending, numbers, intended, teamcity, suitename, document, servers, viewport, device, toc, forbidonly, formats, mochawesome, nohighlighting, employment, differ, slightly, convert, camel, 100, forbidpending, failzero, link, dryrun, asynconly, allowuncaught, append, query, url, exec, xhr, href, stylesheet, rel, generates, page, modern, window, lines, consumer, protocol, exactly, series, represent, exclamation, marks, blue, prefer, minimal, ansi, ftw, escape, stdio, streams, tty, friend, inspired, flat, resembling, predecessor, keys, cased, emits, unicode, render, fantastic, makefile, tail, cat, request, generated, yield, representation, wrap, header, footer, styling, displays, plane, clears, newline, events, beginning, followed, passes, jsonstream, implements, specifications, bottom, gimmicky, simulating, several, comments, suiteteardown, hierarchy, mocking, shared, behaviours, sure, gnu, cygwin, websocket, express, live, menu, additional, melpa, tool, atom, sublime, text, visual, studio, projects, titled, spies, preferences, contributors, 2024, cookie, bylaws, privacy, terms, licensed, copyright, rights, chatting, reserved, logos, indicated, respective, holders, affiliation, endorsement, creative, commons, attribution, international, addition, assuming, runner, locations, higher, aliases, dash, camelcase, doesn, configurations, inherit, keyword, extends, extending, safely, repeated, priorty, folder, sources, appearing, earlier, coupled, concatenated, conflict, merge, priorities, parse, assume, unknown, caution, zsh, among, err_mocha_invalid_exception, includes, snippets, quicker, enjoyable, packages, requested, err_mocha_unsupported, err_mocha_no_files_match_pattern, err_mocha_invalid_reporter, err_mocha_invalid_interface, underspecified, err_mocha_invalid_arg_value, fish, wrong, err_mocha_invalid_arg_type, consumers, against, describes, portability, tutorial, quote, expansion, surround, refrain, wildcard, expresso, element, indicates, prepend, reducing, anyhow, efficient, chunks, identical, pause, unavailable, plans, due, authors, box, listed, guarantee, excluding, cool, collected, transpiled, v12, annotated, prepending, negated, deterministic, variability, notice, boilerplate, shrug, dandy, checklist, troubleshooting, encounter, issues, attempting, existent, objects, avoided, averse, couple, increased, consequently, hypothetical, domyteardown, domysetup, applies, soon, bubble, exiting, effort, naturally, extra, schedule, hint, implies, migrated, opts, consider, declare, multipart, dots, combinations, specifying, ext, ancestor, whether, lookup, ostensibly, forwards, slashes, spawning, dashes, tapversion, key, supplies, diffing, suspected, attempts, distill, noisy, separator, forward, chrome, preferable, complex, criterias, unpredictable, ignorecase, snippet, goes, part, internally, compiled, titles, contained, recurse, folders, manually, typing, nodemon, absolute, prototype, synchronously, finish, augment, ins, merged, mock, appears, entry, guaranteed, glance, seem, unlike, instruct, maintain, backwards, relevant, maintainer, mar, refactoring, point, remember, ready, original, careful, member, exported, truthy, checksomething, operation, logic, choosing, organizational, identically, exporting, username, thingy, behaves, organized, similarly, developers, dsl, affect, flowchart, bring, close, nice, connector, clever, created, restriction, assigning, probably, spinning, creating, resource, repeatedly, explained, later, since, scoping, purposes, userinfo, increase, suited, services, suitable, multi, core, container, agents, regarding, gains, mileage, conditional, extremely, tier, sensitive, requests, ports, automating, hitting, remote, caveats, temp, handles, sockets, unexpectedly, cloud, free, refers, assign, trouble, refer, defines, accomplish, combined, deprecated, future, strongly, assigned, nth, accessed, different, faster, service, mocha_worker_id, ids, unlikely, impossible, gain, said, size, fits, characteristics, optimal, fewer, machine,
Text of the page (random words):
o choose multiple suites describe array function describe only indexof function it should return 1 unless present function this test will be run it should return the index when present function this test will also be run describe only concat function it should return a new array function this test will also be run describe slice function it should return a new array function this test will not be run but tests will have precedence describe array function describe only indexof function it only should return 1 unless present function this test will be run it should return the index when present function this test will not be run note hooks if present will still be executed be mindful not to commit usages of only to version control unless you really mean it to do so one can run mocha with the option forbid only in the continuous integration test command or in a git precommit hook inclusive tests this feature is the inverse of only by appending skip you may tell mocha to ignore test case s anything skipped will be marked as pending and reported as such here s an example of skipping an individual test describe array function describe indexof function it skip should return 1 unless present function this test will not be run it should return the index when present function this test will be run you can also put skip on an entire suite this is equivalent to appending skip onto all tests in the suite hooks in the suite are also skipped describe array function describe skip indexof function it should return 1 unless present function this test will not be run note code in skipped suites that is placed outside of hooks or tests is still executed as mocha will still invoke the suite function to build up the suite structure for visualization best practice use skip instead of commenting tests out you may also skip at runtime using this skip if a test needs an environment or configuration which cannot be detected beforehand a runtime skip is appropriate for example it should only test in the correct environment function if check test environment make assertions else this skip the above test will be reported as pending it s also important to note that calling this skip will effectively abort the test best practice to avoid confusion do not execute further instructions in a test or hook after calling this skip contrast the above test with the following code it should only test in the correct environment function if check test environment make assertions else do nothing because this test does nothing it will be reported as passing best practice don t do nothing a test should make an assertion or use this skip to skip multiple tests in this manner use this skip in a before all hook before function if check test environment setup code else this skip this will skip all it beforeeach aftereach and describe blocks within the suite before after hooks are skipped unless they are defined at the same level as the hook containing this skip describe outer function before function this skip after function will be executed describe inner function before function will be skipped after function will be skipped updated in v7 0 0 skipping a test within an after all hook is disallowed and will throw an exception use a return statement or other means to abort hook execution before mocha v3 0 0 this skip was not supported in asynchronous tests and hooks retry tests you can choose to retry failed tests up to a certain number of times this feature is designed to handle end to end tests functional tests selenium where resources cannot be easily mocked stubbed it s not recommended to use this feature for unit tests this feature does re run a failed test and its corresponding beforeeach aftereach hooks but not before after hooks this retries has no effect on failing hooks note example below was written using selenium webdriver which overwrites global mocha hooks for promise chain describe retries function retry all tests in this suite up to 4 times this retries 4 beforeeach function browser get http www yahoo com it should succeed on the 3rd try function specify this test to only retry up to 2 times this retries 2 expect foo isdisplayed to eventually be true dynamically generating tests given mocha s use of function expressions to define suites and test cases it s straightforward to generate your tests dynamically no special syntax is required plain ol javascript can be used to achieve functionality similar to parameterized tests which you may have seen in other frameworks take the following example const assert require assert function add args return args reduce prev curr prev curr 0 describe add function const tests args 1 2 expected 3 args 1 2 3 expected 6 args 1 2 3 4 expected 10 tests foreach args expected it correctly adds args length args function const res add args assert strictequal res expected the above code will produce a suite with three specs mocha add correctly adds 2 args correctly adds 3 args correctly adds 4 args tests added inside a foreach handler often don t play well with editor plugins especially with right click run features another way to parameterize tests is to generate them with a closure this following example is equivalent to the one above describe add function const testadd args expected function const res add args assert strictequal res expected it correctly adds 2 args testadd args 1 2 expected 3 it correctly adds 3 args testadd args 1 2 3 expected 6 it correctly adds 4 args testadd args 1 2 3 4 expected 10 with top level await you can collect your test data in a dynamic and asynchronous way while the test file is being loaded see also delay for commonjs modules without top level await testfile mjs import assert from assert top level await node v14 8 0 with esm test file const tests await new promise resolve settimeout resolve 5000 args 1 2 expected 3 args 1 2 3 expected 6 args 1 2 3 4 expected 10 in suites asynchronous callbacks are not supported describe add function tests foreach args expected it correctly adds args length args function const res args reduce sum curr sum curr 0 assert strictequal res expected test duration many reporters will display test duration and flag tests that are slow default 75ms as shown here with the spec reporter there are three levels of test duration depicted in the following image fast tests that run within half of the slow threshold will show the duration in green if at all normal tests that run exceeding half of the threshold but still within it will show the duration in yellow slow tests that run exceeding the threshold will show the duration in red to tweak what s considered slow you can use the slow method describe something slow function this slow 300000 five minutes it should take long enough for me to go make a sandwich function timeouts suite level suite level timeouts may be applied to entire test suites or disabled via this timeout 0 this will be inherited by all nested suites and test cases that do not override the value describe a suite of tests function this timeout 500 it should take less than 500ms function done settimeout done 300 it should take less than 500ms as well function done settimeout done 250 test level test specific timeouts may also be applied or the use of this timeout 0 to disable timeouts all together it should take less than 500ms function done this timeout 500 settimeout done 300 hook level hook level timeouts may also be applied describe a suite of tests function beforeeach function done this timeout 3000 a very long environment setup settimeout done 2500 again use this timeout 0 to disable the timeout for a hook in v3 0 0 or newer a parameter passed to this timeout greater than the maximum delay value will cause the timeout to be disabled in v8 0 0 or newer this enabletimeouts has been removed warning with async tests if you disable timeouts via this timeout 0 and then do not call done your test will exit silently diffs mocha supports the err expected and err actual properties of any thrown assertionerror s from an assertion library mocha will attempt to display the difference between what was expected and what the assertion actually saw here s an example of a string diff using inline diffs command line usage mocha spec run tests with mocha commands mocha inspect spec run tests with mocha default mocha init path create a client side mocha setup at path rules behavior allow uncaught allow uncaught errors to propagate boolean a async only require all tests to use a callback async or return a promise boolean b bail abort bail after first test failure boolean check leaks check for global variable leaks boolean delay delay initial execution of root suite boolean dry run report tests without executing them boolean exit force mocha to quit after tests complete boolean fail zero fail test run if no test s encountered boolean forbid only fail if exclusive test s encountered boolean forbid pending fail if pending test s encountered boolean global globals list of allowed global variables array j jobs number of concurrent jobs for parallel use 1 to run in serial number default number of cpu cores 1 p parallel run tests in parallel boolean retries retry failed tests this many times 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 boolean diff show diff on failure boolean default true full trace display full stack traces 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 specific options reporter options 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 to package json for 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 boolean r require require module array default none s sort sort test files 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 grep and fgrep matches 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 chat https discord gg kedn2uxher github https github com mochajs mocha git docs https mochajs org allow uncaught by default mocha will attempt to trap uncaught exceptions thrown from running tests and report these as test failures use allow uncaught to disable this behavior and allow uncaught exceptions to propagate will typically cause the process to crash this flag is useful when debugging particularly difficult to track exceptions async only a enforce a rule that tests must be written in async style meaning each test provides a done callback or returns a promise non compliant tests will be marked as failures bail b causes mocha to stop running tests after the first test failure it encounters corresponding after each and after all hooks are executed for potential cleanup bail does not imply exit check leaks use this option to have mocha check for global variables that are leaked while running tests specify globals that are acceptable via the global option for example check leaks global jquery global mylib compilers compilers was removed in v6 0 0 see further explanation and workarounds dry run new in v9 0 0 report tests without executing any of them neither tests nor hooks exit updated in v4 0 0 tl dr if your tests hang after an upgrade to mocha v4 0 0 or newer use exit for a quick though not necessarily recommended fix prior to version v4 0 0 by default mocha would force its own process to exit once it was finished executing all tests this behavior enables a set of potential problems it s indicative of tests or fixtures harnesses code under test etc which don t clean up after themselves properly ultimately dirty tests can but not always lead to false positive or false negative results hanging most often manifests itself if a server is still listening on a port or a socket is still open etc it can also be something like a runaway setinterval or even an errant promise that never fulfilled the default behavior in v4 0 0 and newer is no exit where previously it was exit the easiest way to fix the issue is to pass exit to the mocha process it can be time consuming to debug because it s not always obvious where the problem is but it is recommended to do so to ensure your tests aren t leaving messes around here are some ideas to get started see the node js guide to debugging use the new async_hooks api example try something like wtfnode use only until you find the test that causes mocha to hang fail zero new in v9 1 0 fail test run if no tests are encountered with exit code 1 forbid only enforce a rule that tests may not be exclusive use of e g describe only or it only is disallowed forbid only causes mocha to fail when an exclusive only d test or suite is encountered and it will abort further test execution forbid pending enforce a rule that tests may not be skipped use of e g describe skip it skip or this skip anywhere is disallowed forbid pending causes mocha to fail when a skipped pending test or suite is encountered and it will abort further test execution global variable name updated in v6 0 0 the option is global and globals is now an alias define a global variable name for example suppose your app deliberately exposes a global named app and yui you may want to add global app global yui global accepts wildcards you could do global bar and it would match foobar barbar etc you can also pass in to ignore all globals global can accept a comma delimited list global app yui is equivalent to global app global yui by using this option in conjunction with check leaks you can specify a whitelist of known global variables that you expect to leak into global scope retries n retries failed tests n times mocha does not retry test failures by default slow ms s ms specify the slow test threshold in milliseconds mocha uses this to highlight test cases that are taking too long slow tests are not considered failures note a test that executes for half of the slow time will be highlighted in yellow with the default spec reporter a tes...
|