Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zaaack committed Oct 8, 2024
1 parent 9b060c0 commit 168b4ee
Show file tree
Hide file tree
Showing 16 changed files with 427 additions and 99 deletions.
10 changes: 7 additions & 3 deletions Foyfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ task('doc', async ctx => {
await ctx.exec(`touch ./docs/.nojekyll`)
})

const JasmineCli = `jasmine --require=tsconfig-paths/register --require=ts-node/register`

task<{ args: string, env: NodeJS.ProcessEnv }>('test', async ctx => {
await ctx.exec(`${JasmineCli} "src/test/*.test.ts" ${ctx.options.args || ''} ${(ctx.task.rawArgs).map(a => `"${a
}"`).join(' ')}`, { env: ctx.options.env || process.env })
// https://github.com/nodejs/node/issues/51555#issuecomment-2290742072
await ctx.env('DISABLE_V8_COMPILE_CACHE', '1').exec(
`tsx --test-concurrency=1 --test "./src/test/*.test.ts" ${ctx.options.args || ''} ${ctx.task.rawArgs
.map((a) => `"${a}"`)
.join(' ')}`,
{ env: ctx.options.env || process.env },
)
})

task('test:update-snap', [{
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ task('some task', async ctx => {
let json = await fs.readJson('./xx.json')
await ctx
.env('NODE_ENV', 'production')
.env('NODE_ENV=production')
.cd('./src')
.exec('some command') // Execute an command
let { stdout } = await ctx.exec('ls', { stdio: 'pipe' }) // Get the stdout, default is empty because it's redirected to current process via `stdio: 'inherit'`.
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"types": "./lib/index",
"sideEffects": false,
"scripts": {
"foy": "ts-node ./src/cli.ts",
"foy": "tsx ./src/cli.ts",
"build": "npm run foy -- build",
"test": "npm run foy -- test",
"test:update-snap": "npm run foy -- test:update-snap",
Expand Down Expand Up @@ -40,14 +40,15 @@
"@types/ejs": "^3.0.4",
"@types/jasmine": "^3.5.14",
"@types/marked": "^1.1.0",
"@types/node": "^14.11.2",
"@types/node": "22.7.5",
"axios": "^0.20.0",
"ejs": "^3.1.5",
"generate-changelog": "^1.8.0",
"jasmine": "^3.6.1",
"marked": "^1.1.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^3.9.0",
"tsx": "^4.19.1",
"typedoc": "^0.26.5",
"typescript": "^5.5.4"
},
Expand Down
Loading

0 comments on commit 168b4ee

Please sign in to comment.