gdirk07 / PokemonChecker

Playing around with APIs
https://gdirk07.github.io/PokemonChecker/
0 stars 0 forks source link

Adding Unit Tests to the App #35

Closed jeremy-jtlo closed 2 years ago

jeremy-jtlo commented 2 years ago

The first 2 tests have been written, to ensure the Jest typescript dependencies are in order be sure to npm install again.

To write a new test, simply declare a new file and label it with .test.ts. General jest documentation says write a test() statement, and have it expect() some things.

You can run them via npm run test once the dependencies have installed correctly. Currently my idea is to include test files in the same directory as their classes, for easier importing and less duplication of structure (I don't want to have to maintain 2 file trees to look 'exactly alike' to find unit tests).

Example:

src/
  DataTransferObjects/
    PokemonDTO.ts
    PokemonDTO.test.ts