Skip to content

Commit

Permalink
Fix: Test script cannot detect test under test directory with deep le…
Browse files Browse the repository at this point in the history
…vel (#708)

* Fix glob pattern in test script

* Update generate.js

Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
Signed-off-by: adamward459 <adamward459@gmail.com>

* Fix test script in generate-typescript.test.js

* Fix test script in generate.js

* Fix missing line break in generate-typescript.test.js

* Fix missing line break in generate-typescript.test.js

---------

Signed-off-by: adamward459 <adamward459@gmail.com>
Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
adamward459 and mcollina authored Feb 23, 2024
1 parent 2632223 commit ce0cfea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const typescriptTemplate = {
dir: 'app-ts',
main: 'app.ts',
scripts: {
test: 'npm run build:ts && tsc -p test/tsconfig.json && c8 node --test -r ts-node/register test/**/*.ts',
test: 'npm run build:ts && tsc -p test/tsconfig.json && c8 node --test -r ts-node/register "test/**/*.ts"',
start: 'npm run build:ts && fastify start -l info dist/app.js',
'build:ts': 'tsc',
'watch:ts': 'tsc -w',
Expand Down
4 changes: 2 additions & 2 deletions test/generate-typescript.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function define (t) {
// by default this will be ISC but since we have a MIT licensed pkg file in upper dir, npm will set the license to MIT in this case
// so for local tests we need to accept MIT as well
t.ok(pkg.license === 'ISC' || pkg.license === 'MIT')
t.equal(pkg.scripts.test, 'npm run build:ts && tsc -p test/tsconfig.json && c8 node --test -r ts-node/register test/**/*.ts')
t.equal(pkg.scripts.test, 'npm run build:ts && tsc -p test/tsconfig.json && c8 node --test -r ts-node/register "test/**/*.ts"')
t.equal(pkg.scripts.start, 'npm run build:ts && fastify start -l info dist/app.js')
t.equal(pkg.scripts['build:ts'], 'tsc')
t.equal(pkg.scripts['watch:ts'], 'tsc -w')
Expand All @@ -143,7 +143,7 @@ function define (t) {
t.equal(pkg.devDependencies.concurrently, cliPkg.devDependencies.concurrently)
t.equal(pkg.devDependencies.typescript, cliPkg.devDependencies.typescript)

const testGlob = pkg.scripts.test.split(' ', 14)[13]
const testGlob = pkg.scripts.test.split(' ', 14)[13].replaceAll('"', '')

t.equal(minimatch.match(['test/routes/plugins/more/test/here/ok.test.ts'], testGlob).length, 1, 'should match glob')
resolve()
Expand Down

0 comments on commit ce0cfea

Please sign in to comment.