-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3dc3f9
commit 4be2ecb
Showing
2 changed files
with
37 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
{ | ||
} | ||
"title": "Test files should contain at least one test case", | ||
"tags": [ | ||
"jasmine", | ||
"jest", | ||
"mocha", | ||
"node", | ||
"tests", | ||
"unused", | ||
"confusing" | ||
], | ||
"quickfix": "infeasible" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
FIXME: add a description | ||
== Why is this an issue? | ||
|
||
// If you want to factorize the description uncomment the following line and create the file. | ||
//include::../description.adoc[] | ||
Test files in JavaScript and TypeScript are meant to contain test cases. These test cases are used to verify the functionality of your code and ensure that it behaves as expected. If a test file doesn't contain any test cases, it's not serving its purpose. | ||
|
||
== Why is this an issue? | ||
A test file without test cases might indicate: | ||
|
||
FIXME: remove the unused optional headers (that are commented out) | ||
* An incomplete test suite: Perhaps the developer started writing tests but didn't finish. | ||
* A mistake: The developer might have accidentally deleted the test cases or moved them to another file. | ||
//=== What is the potential impact? | ||
This rule flags any file that has a ``++.test++`` or ``++.spec++`` suffix but does not contain any test cases defined using the ``++it++`` or ``++test++`` functions from Jasmine, Jest, Mocha, or Node.js testing API. The alternative forms ``++it.only++`` and ``++test.only++`` are recognized, but their use is generally discouraged. | ||
|
||
== How to fix it | ||
//== How to fix it in FRAMEWORK NAME | ||
|
||
To fix a test file that doesn't contain any test cases, you should add test cases or delete the file if it isn't needed. | ||
|
||
=== Code examples | ||
|
||
==== Noncompliant code example | ||
|
||
[source,text,diff-id=1,diff-type=noncompliant] | ||
[source,javascript,diff-id=1,diff-type=noncompliant] | ||
---- | ||
FIXME | ||
// eval.test.js | ||
/* no test cases */ | ||
---- | ||
|
||
==== Compliant solution | ||
|
||
[source,text,diff-id=1,diff-type=compliant] | ||
[source,javascript,diff-id=1,diff-type=compliant] | ||
---- | ||
FIXME | ||
---- | ||
|
||
//=== How does this work? | ||
// eval.test.js | ||
//=== Pitfalls | ||
|
||
//=== Going the extra mile | ||
it('1 + 2 should give 3', () => { | ||
expect(1 + 2).toEqual(3); | ||
}); | ||
---- | ||
|
||
== Resources | ||
=== Documentation | ||
|
||
//== Resources | ||
//=== Documentation | ||
//=== Articles & blog posts | ||
//=== Conference presentations | ||
//=== Standards | ||
//=== External coding guidelines | ||
//=== Benchmarks | ||
* Jasmine docs - https://jasmine.github.io/pages/getting_started.html[Getting started] | ||
* Jest docs - https://jestjs.io/docs/getting-started[Getting started] | ||
* Mocha docs - https://mochajs.org/#getting-started[Getting started] | ||
* Node.js docs - https://nodejs.org/api/test.html[Test runner] |