Jest is the testing framework build by fackbook. It is used to test React App and most commonly javascript with focus of simplicity.
- FAILING TEST = MOST LIKELY A BUG
- Easy to read and understand module / functions
- Survives major refactoring
- Tests entire app
Eslint is the tool that checks your code, analize it and finds common patterns, let's have an example of eslint.
// for example
const a = '1'
// eslint will say "Missing samicolon"
Eslint is the great example for testing test utilites
Eslint support custom rules so you can define your own rule to define a good approch of writing a code in JavaScript
. Just has an ability called Eslint Rule Tester
.
Click here to see an example of Eslint Rule Tester:
ruleTester('semicolon', {
valid: ['var a = 1;','var b = 2;'],
invalid: [{
code: 'var a = 1',
error: 'Missing semicolon'
}]
})
- What is snapshotin JEST?
- - Snapshot means a blue print of component ( part of UI) at a perticular point of time or we can say an Blueprint of object of data that can be predefined.
- What is snapshot testing?
- A Snapshot test renders the UI and takes snapshot of it then we can compare with reference snapshot file and compare both in test so UI does not change unexpectedly!