jsynowiec / node-typescript-boilerplate

Minimalistic project template to jump start a Node.js back-end application in TypeScript. ESLint, Vitest and type definitions included.
Apache License 2.0
2.75k stars 544 forks source link

Vitest is running tests from both pre- and post-build files #63

Open yibe opened 1 month ago

yibe commented 1 month ago
$ npm run build
...
$ npm run test

> node-typescript-boilerplate@0.0.0 test
> vitest run unit

 RUN  v2.1.0 /tmp/node-typescript-boilerplate

 ✓ __tests__/unit/main.test.ts (2)
 ✓ build/__tests__/unit/main.test.js (2)

 Test Files  2 passed (2)
      Tests  4 passed (4)
   Start at  22:08:34
   Duration  389ms (transform 62ms, setup 0ms, collect 59ms, tests 8ms, environment 0ms, prepare 161ms)

Shouldn't we exclude the build directory from the tests by default? https://vitest.dev/config/#exclude

jsynowiec commented 1 month ago

You probably want to use npm run build:release when building so that tests are not transpiled, but I will add that flag with the next update.