TSLint rule to check and fix the minimum number of lines before test cases.
i.e. describe()
, xdescribe()
, it()
, xit()
, test()
, xtest()
.
Install the package using NPM:
npm install tslint-rules-line-before-tests --save-dev
Update your tslint.json
file to extend this package:
{
"rulesDirectory": [
"tslint-rules-line-before-tests"
],
"rules": {
"line-before-tests": true
}
}
Checks minimum number of lines before test cases.
Yes
Takes optional object with following optional properties:
"beforeDescribe"
minimum number of blank lines beforedescribe()
,xdescribe()
. Default value = 2. To disable, set to -1."beforeIt"
minimum number of blank lines beforeit()
,xit()
,test()
,xtest()
. Default value = 1. To disable, set to -1.
"line-before-tests": true
"line-before-tests": [true, {beforeDescribe: 2, beforeIt: 1}]
"line-before-tests": [true, {beforeDescribe: 2}]
"line-before-tests": [true, {beforeIt: 1}]
"line-before-tests": [true, {beforeDescribe: 2, beforeIt: -1}]
"line-before-tests": [true, {beforeDescribe: -1, beforeIt: 1}]
If you are interested to see exactly where it will throw error, you can take a look at tests:
For below configuration, check test file here.
"line-before-tests": [true, {beforeDescribe: 2, beforeIt: -1}]
For below configuration, check test file here.
"line-before-tests": [true, {beforeDescribe: -1, beforeIt: 1}]
# build
yarn build
# test
yarn test