When using testing frameworks like Mocha and Jest, appending .only()
to the test function allows running a single test case for a
file. Using .only()
means no other test from this file is executed. This is useful when debugging a specific use case.
describe("MyClass", function () {
it.only("should run correctly", function () { // Noncompliant
/*...*/
});
});
However, it should not be used in production or development, as it is likely a leftover from debugging and serves no purpose in those contexts. It
is strongly recommended not to include .only()
usages in version control.
describe("MyClass", function () {
it("should run correctly", function () {
/*...*/
});
});