JumpStart Bootcamp: Intro to Testing

Testing

Older method: Dev and testers are separated into different teams
Cons: Long feedback cycles, human error, manpower needed, production pipeline blockage, poor quality (due to lack of ownership), disagreements between teams,
Pros: Testers are less biased
Testers use SVN, usually still use manual testing

Now: Devs and QAs
QAs uses automated testing (Integration tests: Insomnia, Postman. E2E: Cypress, Selenium)
If bug is found in exploratory testing, bug-catching can be automated
Pros: Short feedback cycles, less human errors,

Unit testing is important because the more tests you write for your units, the more confident you can be about it working as expected. When bugs are caught in Integration/ E2E tests, writing better unit tests that catches the bugs and passing them ensure that if the code break for a similar future case, it will be caught.

Using Jest

jestjs.io

in package.json

“scripts”: {
“test”: “jest”,
“test:watch”: “jest –watch”, // continuously test (on save)
“test:coverage”: “jest –coverage” // check coverage for all functions
},
Matchers:
.toBe() = compare values (use this instead of toEqual whenever possible)
.toEqual() = iterates over arrays/ objects
.toBeTruthy() / .toBeFalsy() = not strict (usually use expect(value).toBe(true); instead)
.toBeGreaterThan(), etc
.toMatch() = match against regex
.toContain() = check array if it contains item
.not.toBe()
Set up/ Tear down
beforeEach(), afterEach(), beforeAll(), afterAll()
describe() // encapsulates test cases

devdocs.io (for checking docs)

 

Leave a comment

Design a site like this with WordPress.com
Get started