Modify rule S6426: Adapt to LaYC (#2567)

This commit is contained in:
Yassin Kammoun 2023-07-20 11:46:48 +02:00 committed by GitHub
parent ae719d7562
commit 8d399746fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,12 +1,11 @@
== Why is this an issue?
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.
[source,javascript]
[source,javascript,diff-id=1,diff-type=noncompliant]
----
describe("MyClass", function () {
it.only("should run correctly", function () {
it.only("should run correctly", function () { // Noncompliant
/*...*/
});
});
@ -14,7 +13,7 @@ describe("MyClass", function () {
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.
[source,javascript]
[source,javascript,diff-id=1,diff-type=compliant]
----
describe("MyClass", function () {
it("should run correctly", function () {
@ -27,6 +26,6 @@ describe("MyClass", function () {
=== Documentation
- 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]
- https://mochajs.org/#exclusive-tests[Mocha - Exclusive tests]
- https://jestjs.io/docs/next/api#testonlyname-fn-timeout[Jest - ``++test.only()++``]
- https://jestjs.io/docs/next/api#describeonlyname-fn[Jest - ``++describe.only()++``]