farhan-helmy / carisurau

https://carisurau.com
MIT License
66 stars 36 forks source link

Added Base Unit-Test #70

Closed Xavier-IV closed 1 year ago

Xavier-IV commented 1 year ago

Overview

You can use this as a base to setup your project to use test.

Using Vitest: https://vitest.dev/

But any prior experience with Jest will do as well.

Usage

# One time execution, useful for pipeline
$ yarn test

# Continuously watch changes on spec
$ yarn test:watch

Example output ran:

$ vitest run

 RUN  v0.33.0 /Users/zafranudin.zafrin/Projects/learn/ratemysurau

 ✓ src/utils/random.spec.ts (2)
 ✓ src/utils/uploadthing.spec.ts (3)
 ✓ src/server/services/generate-surau-verification.spec.ts (3)

 Test Files  3 passed (3)
      Tests  8 passed (8)
   Start at  18:26:01
   Duration  298ms (transform 128ms, setup 0ms, collect 156ms, tests 10ms, environment 0ms, prepare 201ms)

✨  Done in 1.30s.

Disclaimer

This is by no mean a complete test, you can keep on adding more with the example I provided. Feel free to add this into the pipeline as well.

Also this does not cover e2e and frontend test, but its a good start.

Xavier-IV commented 1 year ago

For approvers, kindly verify with pull/clone first, since I'm not sure if it'll break any local setup you might have.

Otherwise I don't see any breaking changes.