JavaScript :: Testing :: Jest :: Courses :: JavaScript Unit Testing with Jest :: 2. Writing Your First Unit Test with Jest
⪼ Made with 💜 by Polyglot.
- JavaScript 2022
- Jest v29
- Node.js v18
- npm v8
- Manual testing takes too much time
- Unit tests can be run automatically
- Give us confidence in the quality of our source code
- Can facilitate Test-Driven Development (TDD)
- Can act like documentation
- E2E Tests
- Integeration Tests
- Unit Tests
- Why are unit tests so important?
- Jest installation
- Writing basic unit tests with Jest
- Using common matchers
- Using mocks
- Testing asyncronous functions
- Measuring code coverage
- No configuration required to get started
- Highly intuitive API
- Runs test in parallel
- Works with the vast majority of JS projects
- Great documentation and a large community
» npm install jest --save-dev
add "jest" to the
testscript
» npm test
-
name: Test's Name -
fn: Test Function -
timeout: The timeout for an async function test
The argument for the
expectfunction is the value that you want to validate (actual)
