Skip to content

Commit

Permalink
Jest Unit tests for Node Typescript app
Browse files Browse the repository at this point in the history
  • Loading branch information
Kazaz-Or committed May 20, 2023
1 parent e333fe2 commit 53be44e
Show file tree
Hide file tree
Showing 24 changed files with 4,507 additions and 0 deletions.
34 changes: 34 additions & 0 deletions TypeScriptUnitTestsWithJest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Jest unit tests using Typescript

This "project" was done for learning proposes. The application written with Typescript wasn't the focus of this project, the goal was to learn Jest features for unit testing with NodeJS Typescript applications.


## Jest Features covered:

* Different Asserts
* Parameterize
* Hooks (Setup, Teardown)
* Testing for Errors
* Code Coverage
* Test Doubles (Stubs, Fakes, Mocks, Spies, Mock Modules)

## Application Overview

### Reservation handler application

This simple app handles reservations for meeting rooms:

* Users can register with a username and password.
* Users can login with a user and a password.
* Logged in users can create, view, update or delete reservations.

## Getting Started

To run the application, simply run:
```bash
npm start
```
To run the tests, simply run:
```bash
npm test
```
16 changes: 16 additions & 0 deletions TypeScriptUnitTestsWithJest/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Config } from '@jest/types'

const baseDir = '<rootDir>/src'
const baseTestDir = '<rootDir>/src/tests'

const config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: 'node',
verbose: true,
collectCoverage: true,
collectCoverageFrom: [
`${baseDir}/**/*.ts`
]
}

export default config;
Loading

0 comments on commit 53be44e

Please sign in to comment.