fastify / fastify-cli

Run a Fastify application with one command!
MIT License
644 stars 160 forks source link

Fix: Test script cannot detect test under test directory with deep level #708

Closed adamward459 closed 5 months ago

adamward459 commented 5 months ago

Checklist

System information

The demo can be found here Mac os: 14.3.1 (23D60) Node: v21.6.2 Npm: 10.2.4

Reproduce

List all tests under the test directory

➜  demo-fastify git:(main) find ./test -name "*.test.ts"
./test/plugins/support.test.ts
./test/routes/example.test.ts
./test/routes/root.test.ts
./test/routes/routes/example.test.ts
./test/routes/routes/root.test.ts
./test/routes/routes/routes/example.test.ts
./test/routes/routes/routes/root.test.ts

Run test command, the test command can only figure out files at first level.

➜  demo-fastify git:(main) npm test

> demo-fastify@1.0.0 test
> npm run build:ts && tsc -p test/tsconfig.json && c8 node --test -r ts-node/register test/**/*.ts

> demo-fastify@1.0.0 build:ts
> tsc

✔ support works standalone (9.705125ms)
✔ example is loaded (3074.605459ms)
✔ default root route (3067.900959ms)
ℹ tests 3
ℹ suites 0
ℹ pass 3
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 4618.984375
--------------------|---------|----------|---------|---------|-------------------
File                | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
--------------------|---------|----------|---------|---------|-------------------
All files           |     100 |      100 |     100 |     100 |                   
 src                |     100 |      100 |     100 |     100 |                   
  app.ts            |     100 |      100 |     100 |     100 |                   
 src/plugins        |     100 |      100 |     100 |     100 |                   
  sensible.ts       |     100 |      100 |     100 |     100 |                   
  support.ts        |     100 |      100 |     100 |     100 |                   
 src/routes         |     100 |      100 |     100 |     100 |                   
  root.ts           |     100 |      100 |     100 |     100 |                   
 src/routes/example |     100 |      100 |     100 |     100 |                   
  index.ts          |     100 |      100 |     100 |     100 |                   
--------------------|---------|----------|---------|---------|-------------------

After I change the pattern to include double quote mark, here is the result:

➜  demo-fastify git:(main) ✗ npm test

> demo-fastify@1.0.0 test
> npm run build:ts && tsc -p test/tsconfig.json && c8 node --test -r ts-node/register "test/**/*.ts"

> demo-fastify@1.0.0 build:ts
> tsc

✔ test/helper.ts (2398.497417ms)
✔ support works standalone (9.181417ms)
✔ example is loaded (4585.684167ms)
✔ default root route (4705.922125ms)
✔ example is loaded (4690.084708ms)
✔ default root route deep (4674.864291ms)
✔ example is loaded (4636.318958ms)
✔ default root route (4657.602333ms)
ℹ tests 8
ℹ suites 0
ℹ pass 8
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 7223.8055
--------------------|---------|----------|---------|---------|-------------------
File                | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
--------------------|---------|----------|---------|---------|-------------------
All files           |     100 |      100 |     100 |     100 |                   
 src                |     100 |      100 |     100 |     100 |                   
  app.ts            |     100 |      100 |     100 |     100 |                   
 src/plugins        |     100 |      100 |     100 |     100 |                   
  sensible.ts       |     100 |      100 |     100 |     100 |                   
  support.ts        |     100 |      100 |     100 |     100 |                   
 src/routes         |     100 |      100 |     100 |     100 |                   
  root.ts           |     100 |      100 |     100 |     100 |                   
 src/routes/example |     100 |      100 |     100 |     100 |                   
  index.ts          |     100 |      100 |     100 |     100 |                   
adamward459 commented 5 months ago

Can you retry the window job @mcollina ? i don't know what went wrong with it