You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fact that code inside of a skipped suite is executed, is potentially
counter-intuitive. By using alternative phrasing, we make it clear how
mocha handles code in skipped suites.
Closes#3932
Copy file name to clipboardExpand all lines: docs/index.md
+14-10Lines changed: 14 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -566,32 +566,36 @@ _Note_: Hooks, if present, will still be executed.
566
566
567
567
## Inclusive Tests
568
568
569
-
This feature is the inverse of `.only()`. By appending `.skip()`, you may tell Mocha to simply ignore these suite(s) and test case(s). Anything skipped will be marked as [pending](#pending-tests), and reported as such. Here's an example of skipping an entire suite:
569
+
This feature is the inverse of `.only()`. By appending `.skip()`, you may tell Mocha to simply ignore test case(s). Anything skipped will be marked as [pending](#pending-tests), and reported as such. Here's an example of skipping an individual test:
it('should return the index when present', function() {
579
+
// this test will be run
580
+
});
575
581
});
576
582
});
577
583
```
578
584
579
-
Or a specific test-case:
585
+
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.
it('should return the index when present', function() {
589
-
// this test will be run
590
-
});
591
593
});
592
594
});
593
595
```
594
596
597
+
_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.
598
+
595
599
> _Best practice_: Use `.skip()` instead of commenting tests out.
596
600
597
601
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:
0 commit comments