frandiox / vite-ssr

Use Vite for server side rendering in Node
MIT License
830 stars 92 forks source link

Add unit tests #75

Open m4rvr opened 3 years ago

m4rvr commented 3 years ago

This PR adds some basic unit test setup with jest + esbuild-jest. Currently, only a few utils are tested. Also, the test script/command needs to be run manually.

frandiox commented 3 years ago

@MarvinRudolph Thanks! As mentioned on Twitter DMs, we are going to use uvu instead of Jest. The other PR was already merged so we should adapt this PR to the new structure.

@m3hari How should we handle unit tests like the ones in this PR? Also in test/specs or somewhere else? 🤔

m3hari commented 3 years ago

Apologies for the late reply, I think unit tests are better placed next to the file to be tested. uvu should find it with minor changes on the test command. Here is the docs for uvu test file matching

frandiox commented 3 years ago

@m3hari Thanks!

@MarvinRudolph Do you want to transform this to use uvu? For example, if you want to test utils/html.ts then the spec can be located next to it, in utils/html.unit.ts or utils/html.spec.ts.