forked from nocobase/nocobase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: run vitest with coverage (nocobase#3802)
* chore: vitest coverage * chore: vitest coverage config * chore: vitest coverage config * chore: vitest coverage config * chore: report storage dir * chore: exclude lib dir * chore: coverage report dir * fix: client and server coverage * fix: bug * fix: coverage storage dir --------- Co-authored-by: dream2023 <[email protected]>
- Loading branch information
Showing
21 changed files
with
488 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,4 @@ tsconfig.paths.json | |
ncc-cache/ | ||
yarn--** | ||
v8-compile-cache-** | ||
vitest.config.mts.timestamp-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const { run } = require('../util'); | ||
const fg = require('fast-glob'); | ||
|
||
const coreClientPackages = ['packages/core/client', 'packages/core/sdk']; | ||
const isCore = (dir) => dir.startsWith('packages/core'); | ||
|
||
const getPackagesDir = (isClient) => { | ||
if (process.argv.length > 3 && !process.argv[3].startsWith('-')) { | ||
return [process.argv[3]]; | ||
} | ||
|
||
const allPackageJson = fg.sync(['packages/*/*/package.json', 'packages/*/*/*/package.json'], { | ||
cwd: process.cwd(), | ||
onlyFiles: true, | ||
}); | ||
const res = allPackageJson.map((pkg) => pkg.replace('/package.json', '')); | ||
return isClient | ||
? res.filter((dir) => (isCore(dir) ? coreClientPackages.includes(dir) : true)) | ||
: res.filter((dir) => (isCore(dir) ? !coreClientPackages.includes(dir) : true)); | ||
}; | ||
|
||
module.exports = (cli) => { | ||
cli.command('test-coverage:server').action(async () => { | ||
const packageRoots = getPackagesDir(false); | ||
for (const dir of packageRoots) { | ||
try { | ||
await run('yarn', ['test:server', '--coverage', dir]); | ||
} catch (e) { | ||
continue; | ||
} | ||
} | ||
}); | ||
|
||
cli.command('test-coverage:client').action(async () => { | ||
const packageRoots = getPackagesDir(true); | ||
for (const dir of packageRoots) { | ||
try { | ||
await run('yarn', ['test:client', '--coverage', dir]); | ||
} catch (e) { | ||
continue; | ||
} | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.