33 lines
1017 B
Plaintext
Raw Normal View History

== Why is this an issue?
Testing frameworks like Mocha and Jest provide a way to run a single test case for a file by appending `.only()` to the test function. This is convenient when debugging a specific use case. It makes, however, no sense to have it in production or development, and it was likely left by mistake after such a debugging session.
Therefore, it is strongly recommended not to commit usages of `.only()` to version control.
=== Noncompliant code example
[source,javascript]
----
describe("MyClass", function () {
it.only("should run correctly", function () {
/*...*/
});
});
----
=== Compliant solution
[source,javascript]
----
describe("MyClass", function () {
it("should run correctly", function () {
/*...*/
});
});
----
== Resources
- https://mochajs.org/#exclusive-tests[exclusive tests in Mocha]
- https://jestjs.io/docs/next/api#testonlyname-fn-timeout[test.only() in Jest]
- https://jestjs.io/docs/next/api#describeonlyname-fn[describe.only() in Jest]