Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading