Skip to content

Commit

Permalink
multiplatform package.json and test:watch (#1037)
Browse files Browse the repository at this point in the history
* rm command (not in windows) has been replaced with rimraf

* cross-env has been extended to all the scripts which contain enviroment variables

* & parallel operator (not in windows) has been replaced with npm-run-all run-p command

* cp command (not in windows) has been replaced with shx, rimraf is no more necessary

* added script test:watch, it uses ts-jest to check if a file has been changed, then it runs the tests

* fix test

* update test:integration

* update test:integration

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: minotogna <[email protected]>
  • Loading branch information
3 people authored Nov 30, 2021
1 parent 2e91ce3 commit 51b748e
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 62 deletions.
18 changes: 16 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
module.exports = {
roots: ['<rootDir>/dist/'],
preset: 'ts-jest/presets/js-with-ts',
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/'],
roots: ['<rootDir>'],
verbose: true,
testRegex: 'dist/test/integration/index.js',
testMatch: ['**/integration/index.ts'],
moduleDirectories: ['node_modules'],
moduleNameMapper: {
"@common/(.*)": "<rootDir>/common/$1",
"@core/(.*)": "<rootDir>/core/$1",
"@server/(.*)": "<rootDir>/server/$1",
"@test/(.*)": "<rootDir>/test/$1"
},
globals: {
'ts-jest': {
tsconfig: 'tsconfig.test.json',
},
},
}
24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,23 @@
"migrate-fra": "ts-node tools/dataMigration/index.ts",
"build": "yarn build:client && yarn build:server && yarn build:copy",
"build:server": "yarn tsc --project tsconfig.server.json && yarn tscpaths -v -p tsconfig.server.paths.json -s ./server -o ./dist",
"build:client": "NODE_ENV=production webpack --config webpack.config.babel.js",
"build:copy": "cp -a server/db/migration/* dist/server/db/migration/. && cp -a web-resources dist/ && cp -a server/static dist/server/",
"build:watch": "NODE_ENV=development webpack --config webpack.config.babel.js --watch",
"build:dev-server": "NODE_ENV=development webpack serve --config webpack.config.babel.js",
"build:client": "cross-env NODE_ENV=production webpack --config webpack.config.babel.js",
"build:copy": "shx cp -a server/db/migration/* dist/server/db/migration/. && shx cp -a web-resources dist/ && shx cp -a server/static dist/server/",
"build:watch": "cross-env NODE_ENV=development webpack --config webpack.config.babel.js --watch",
"build:dev-server": "cross-env NODE_ENV=development webpack serve --config webpack.config.babel.js",
"build:prod:report": "cross-env NODE_ENV=production BUILD_REPORT=true webpack --display-error-details -p --config webpack.config.babel.js",
"build:prod": "cross-env NODE_ENV=production webpack --display-error-details -p --config webpack.config.babel.js",
"clean": "rm -rf dist/",
"clean": "shx rm -rf dist/",
"start": "node dist/server",
"watch": "yarn build:dev-server & yarn watch:server",
"watch-debug": "yarn build:dev-server & yarn watch:server-debug",
"watch": "run-p build:dev-server watch:server",
"watch-debug": "run-p build:dev-server watch:server-debug",
"watch:server": "ts-node-dev server",
"watch:server-debug": "NODE_ENV=development nodemon -e js --inspect --watch server server/serverLocal.js",
"watch:server-debug": "cross-env NODE_ENV=development nodemon -e js --inspect --watch server server/serverLocal.js",
"create-migration": "./server/db/migration/create-migration.sh",
"run-migrations": "./server/db/migration/run-migrations.sh",
"test": "mochapack --webpack-config webpack.config.babel.test.js \"test/unit/*.ts\"",
"//TODO:": "echo handle next command betters, and env variables",
"test:build": "yarn tsc --project tsconfig.test.json && yarn tscpaths -v -p tsconfig.test.paths.json -s ./server -o ./dist",
"test:integration": "yarn test:build && cp .env.test dist/ && jest --setupFiles dotenv/config",
"test:integration": "yarn jest --no-cache --detectOpenHandles --setupFiles dotenv/config",
"test:watch": "yarn jest --no-cache --detectOpenHandles --watchAll --setupFiles dotenv/config",
"preversion": "git diff --quiet || { echo \"Working directory is dirty\"; exit 1; }; yarn test",
"postversion": "git push --tags && git push && echo \"Successfully released version $npm_package_version!\"",
"prepare": "husky install",
Expand Down Expand Up @@ -120,16 +119,19 @@
"mocha": "^8.4.0",
"mochapack": "^2.1.2",
"nodemon": "^2.0.12",
"npm-run-all": "^4.1.5",
"null-loader": "^4.0.0",
"pdfjs-dist": "^2.8.335",
"prettier": "^2.3.2",
"puppeteer": "^5.5.0",
"react-refresh": "^0.10.0",
"sass": "^1.35.2",
"sass-loader": "^12.1.0",
"shx": "^0.3.3",
"source-map-loader": "^3.0.0",
"style-loader": "^3.0.0",
"terser-webpack-plugin": "^5.1.4",
"ts-jest": "^27.0.7",
"ts-migrate": "^0.1.20",
"ts-node": "^10.1.0",
"ts-node-dev": "^1.1.8",
Expand Down
24 changes: 1 addition & 23 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
{
"allowSyntheticDefaults": true,
"include": ["core", "common", "server",
"test/integration"
],
"exclude": ["node_modules"],
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"module": "CommonJS",
"moduleResolution": "Node",
"noImplicitAny": true,
"outDir": "./dist/",
"baseUrl": ".",
"paths": {
"@core/*": ["core/*"],
"@common/*": ["common/*"],
"@server/*": ["server/*"],
"@test/*": ["test/*"]
},
"target": "es2020",
"lib": ["es2020", "esnext"]
}
"extends": "./tsconfig.json"
}
Loading

0 comments on commit 51b748e

Please sign in to comment.