This repository serves as the solution to a task writing unit tests using the Jest API.
# run unit tests
$ npm run test
# with logging
$ npm run test:verbose
src/01-simple-tests/index.test.ts
Write unit tests for the simpleCalculator
function, which performs basic mathematical operations - addition, subtraction, division, multiplication, and exponentiation. Your task is to verify that the operations are executed correctly and that the function returns null
for invalid input.
src/02-table-tests/index.test.ts
Rewrite the tests written in the previous task using the table-driven testing approach, utilizing the appropriate Jest API.
src/03-error-handling-async/index.test.ts
Test functions that work asynchronously/throw/reject exceptions.
src/04-test-class/index.test.ts
Test a class representing a bank account that implements corresponding operations.
src/05-partial-mocking/index.test.ts
Utilize the Jest API to partially mock the contents of a module.
src/06-mocking-node-api/index.test.ts
Test the proper usage of the Node.js API based on commonly used APIs such as the fs
module, as well as setTimeout
and setInterval
.
src/07-mocking-lib-api/index.test.ts
Test the function that utilize library APIs is working correctly (with commonly used libraries such as axios
and lodash
).
src/08-snapshot-testing/index.test.ts
Use snapshot testing with Jest and compare it to regular comparison testing.