edits to page headers (#33887)
This commit is contained in:
parent
8b0d1206a8
commit
41fb553ee3
1 changed files with 11 additions and 8 deletions
|
@ -1,35 +1,37 @@
|
||||||
[[development-unit-tests]]
|
[[development-unit-tests]]
|
||||||
=== Unit Testing
|
=== Unit Testing
|
||||||
|
|
||||||
We use unit tests to make sure that individual software units of Kibana perform as they were designed to.
|
We use unit tests to make sure that individual software units of {kib} perform as they were designed to.
|
||||||
|
|
||||||
[float]
|
[float]
|
||||||
==== Current Frameworks
|
=== Current Frameworks
|
||||||
|
|
||||||
Kibana is migrating unit testing from `Mocha` to `Jest`. Legacy unit tests still exist in `Mocha` but all new unit tests should be written in `Jest`.
|
{kib} is migrating unit testing from `Mocha` to `Jest`. Legacy unit tests still exist in `Mocha` but all new unit tests should be written in `Jest`.
|
||||||
|
|
||||||
[float]
|
[float]
|
||||||
==== Mocha (legacy)
|
==== Mocha (legacy)
|
||||||
|
|
||||||
Mocha tests are contained in `__tests__` directories.
|
Mocha tests are contained in `__tests__` directories.
|
||||||
|
|
||||||
===== Running Mocha Unit Tests
|
*Running Mocha Unit Tests*
|
||||||
|
|
||||||
["source","shell"]
|
["source","shell"]
|
||||||
-----------
|
-----------
|
||||||
yarn test:mocha
|
yarn test:mocha
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
[float]
|
||||||
==== Jest
|
==== Jest
|
||||||
Jest tests are stored in the same directory as source code files with the `.test.{js,ts,tsx}` suffix.
|
Jest tests are stored in the same directory as source code files with the `.test.{js,ts,tsx}` suffix.
|
||||||
|
|
||||||
===== Running Jest Unit Tests
|
*Running Jest Unit Tests*
|
||||||
|
|
||||||
["source","shell"]
|
["source","shell"]
|
||||||
-----------
|
-----------
|
||||||
yarn test:jest
|
yarn test:jest
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
[float]
|
||||||
===== Writing Jest Unit Tests
|
===== Writing Jest Unit Tests
|
||||||
|
|
||||||
In order to write those tests there are two main things you need to be aware of.
|
In order to write those tests there are two main things you need to be aware of.
|
||||||
|
@ -39,8 +41,8 @@ test files with `babel-jest` both techniques are needed
|
||||||
specially for the tests implemented on Typescript in order to benefit from the
|
specially for the tests implemented on Typescript in order to benefit from the
|
||||||
auto-inference types feature.
|
auto-inference types feature.
|
||||||
|
|
||||||
|
[float]
|
||||||
====== Jest.mock vs Jest.doMock
|
===== Jest.mock vs Jest.doMock
|
||||||
|
|
||||||
Both methods are essentially the same on their roots however the `jest.mock`
|
Both methods are essentially the same on their roots however the `jest.mock`
|
||||||
calls will get hoisted to the top of the file and can only reference variables
|
calls will get hoisted to the top of the file and can only reference variables
|
||||||
|
@ -49,7 +51,8 @@ reference pretty much any variable we want, however we have to assure those refe
|
||||||
variables are instantiated at the time we need them which lead us to the next
|
variables are instantiated at the time we need them which lead us to the next
|
||||||
section where we'll talk about our jest mock files pattern.
|
section where we'll talk about our jest mock files pattern.
|
||||||
|
|
||||||
====== Jest Mock Files Pattern
|
[float]
|
||||||
|
===== Jest Mock Files Pattern
|
||||||
|
|
||||||
Specially on typescript it is pretty common to have in unit tests
|
Specially on typescript it is pretty common to have in unit tests
|
||||||
`jest.doMock` calls which reference for example imported types. Any error
|
`jest.doMock` calls which reference for example imported types. Any error
|
||||||
|
|
Loading…
Reference in a new issue