Skip to content

Commit

Permalink
chore: set up ZENSTACK_TEST environment variable during test setup (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 authored Feb 22, 2024
1 parent da53753 commit 65473bb
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 11 deletions.
4 changes: 3 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export default {
// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,

globalSetup: path.join(__dirname, './test-setup.ts'),
globalSetup: path.join(__dirname, './script/test-global-setup.ts'),

setupFiles: [path.join(__dirname, './script/set-test-env.ts')],

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"scripts": {
"build": "pnpm -r build",
"lint": "pnpm -r lint",
"test": "ZENSTACK_TEST=1 pnpm -r --parallel run test --silent --forceExit",
"test-ci": "ZENSTACK_TEST=1 pnpm -r --parallel run test --silent --forceExit",
"test": "pnpm -r --parallel run test --silent --forceExit",
"test-ci": "pnpm -r --parallel run test --silent --forceExit",
"test-scaffold": "tsx script/test-scaffold.ts",
"publish-all": "pnpm --filter \"./packages/**\" -r publish --access public",
"publish-preview": "pnpm --filter \"./packages/**\" -r publish --force --registry https://preview.registry.zenstack.dev/",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && copyfiles ./package.json ./README.md ./LICENSE dist && copyfiles -u 1 ./src/plugin.zmodel dist && pnpm pack dist --pack-destination '../../../../.build'",
"watch": "tsc --watch",
"lint": "eslint src --ext ts",
"test": "ZENSTACK_TEST=1 jest",
"test": "jest",
"prepublishOnly": "pnpm build"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/swr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && tsup-node --config ./tsup.config.ts && copyfiles ./package.json ./README.md ./LICENSE dist && pnpm pack dist --pack-destination '../../../../.build'",
"watch": "concurrently \"tsc --watch\" \"tsup-node --config ./tsup.config.ts --watch\"",
"lint": "eslint src --ext ts",
"test": "ZENSTACK_TEST=1 jest",
"test": "jest",
"prepublishOnly": "pnpm build"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/tanstack-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && tsup-node --config ./tsup.config.ts && tsup-node --config ./tsup-v5.config.ts && node scripts/postbuild && copyfiles ./package.json ./README.md ./LICENSE dist && pnpm pack dist --pack-destination '../../../../.build'",
"watch": "concurrently \"tsc --watch\" \"tsup-node --config ./tsup.config.ts --watch\" \"tsup-node --config ./tsup-v5.config.ts --watch\"",
"lint": "eslint src --ext ts",
"test": "ZENSTACK_TEST=1 jest",
"test": "jest",
"prepublishOnly": "pnpm build"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/trpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && copyfiles ./package.json ./README.md ./LICENSE 'res/**/*' dist && pnpm pack dist --pack-destination '../../../../.build'",
"watch": "tsc --watch",
"lint": "eslint src --ext ts",
"test": "ZENSTACK_TEST=1 jest",
"test": "jest",
"prepublishOnly": "pnpm build"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"bundle": "rimraf bundle && pnpm lint --max-warnings=0 && node build/bundle.js --minify",
"watch": "tsc --watch",
"lint": "eslint src tests --ext ts",
"test": "ZENSTACK_TEST=1 jest",
"test": "jest",
"prepublishOnly": "pnpm build",
"postinstall": "node bin/post-install.js"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && copyfiles ./package.json ./README.md ./LICENSE dist && pnpm pack dist --pack-destination '../../../.build'",
"watch": "tsc --watch",
"lint": "eslint src --ext ts",
"test": "ZENSTACK_TEST=1 jest",
"test": "jest",
"prepublishOnly": "pnpm build"
},
"publishConfig": {
Expand Down
1 change: 1 addition & 0 deletions script/set-test-env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
process.env.ZENSTACK_TEST = '1';
2 changes: 1 addition & 1 deletion test-setup.ts → script/test-global-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs';
import path from 'path';

export default function globalSetup() {
if (!fs.existsSync(path.join(__dirname, '.test/scaffold/package-lock.json'))) {
if (!fs.existsSync(path.join(__dirname, '../.test/scaffold/package-lock.json'))) {
console.error(`Test scaffold not found. Please run \`pnpm test-scaffold\` first.`);
process.exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"lint": "eslint . --ext .ts",
"test": "ZENSTACK_TEST=1 jest"
"test": "jest"
},
"keywords": [],
"author": "",
Expand Down

0 comments on commit 65473bb

Please sign in to comment.