mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
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]]
|
||||
=== 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]
|
||||
==== 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]
|
||||
==== Mocha (legacy)
|
||||
|
||||
Mocha tests are contained in `__tests__` directories.
|
||||
|
||||
===== Running Mocha Unit Tests
|
||||
*Running Mocha Unit Tests*
|
||||
|
||||
["source","shell"]
|
||||
-----------
|
||||
yarn test:mocha
|
||||
-----------
|
||||
|
||||
[float]
|
||||
==== Jest
|
||||
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"]
|
||||
-----------
|
||||
yarn test:jest
|
||||
-----------
|
||||
|
||||
[float]
|
||||
===== Writing Jest Unit Tests
|
||||
|
||||
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
|
||||
auto-inference types feature.
|
||||
|
||||
|
||||
====== Jest.mock vs Jest.doMock
|
||||
[float]
|
||||
===== Jest.mock vs Jest.doMock
|
||||
|
||||
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
|
||||
|
@ -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
|
||||
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
|
||||
`jest.doMock` calls which reference for example imported types. Any error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue