/testchecking

Primary LanguageJavaScriptMIT LicenseMIT


This repo is made to learn JEST framework

What is JEST?

Jest is the testing framework build by fackbook. It is used to test React App and most commonly javascript with focus of simplicity.

Click here to see a Screenshot of JEST testing:

Pros of testing approch using JEST:

  1. FAILING TEST = MOST LIKELY A BUG
  2. Easy to read and understand module / functions
  3. Survives major refactoring
  4. Tests entire app

What is Eslint?

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'
    }]
})

Snapshot testing with JEST

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!