-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jest Unit tests for Node Typescript app
- Loading branch information
Kazaz-Or
committed
May 20, 2023
1 parent
e333fe2
commit 53be44e
Showing
24 changed files
with
4,507 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.