From 9ea8ae1c24a5aaf27388e95529a4190e2d2997a1 Mon Sep 17 00:00:00 2001 From: Dennis Kigen Date: Tue, 12 Sep 2023 13:43:32 +0300 Subject: [PATCH] (chore) Update test scripts and their related documentation (#754) --- README.md | 46 +++++++++++++++++-- packages/apps/esm-devtools-app/package.json | 3 +- .../esm-implementer-tools-app/package.json | 3 +- packages/apps/esm-login-app/package.json | 3 +- .../apps/esm-offline-tools-app/package.json | 3 +- .../esm-primary-navigation-app/package.json | 3 +- packages/framework/esm-api/package.json | 3 +- .../framework/esm-breadcrumbs/package.json | 3 +- packages/framework/esm-config/package.json | 3 +- .../esm-dynamic-loading/package.json | 3 +- .../framework/esm-extensions/package.json | 3 +- .../framework/esm-feature-flags/package.json | 3 +- packages/framework/esm-framework/package.json | 3 +- packages/framework/esm-offline/package.json | 3 +- packages/framework/esm-state/package.json | 3 +- .../framework/esm-styleguide/package.json | 3 +- packages/framework/esm-utils/package.json | 3 +- turbo.json | 24 +++------- 18 files changed, 81 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 11f6626c0..c6004e82b 100644 --- a/README.md +++ b/README.md @@ -104,11 +104,51 @@ yarn build ./dist/cli.js ``` -### Testing +### Running tests -Run `yarn test` in the directory containing the package you want to test. +To run tests for all packages, run: -Run `yarn lerna run test` to run all the tests in this repository. +```bash +yarn turbo test +``` + +To run tests in `watch` mode, run: + +```bash +yarn turbo test:watch +``` + +To run tests for a specific package, pass the package name to the `--filter` flag. For example, to run tests for `esm-patient-conditions-app`, run: + +```bash +yarn turbo test --filter="esm-patient-conditions-app" +``` + +To run a specific test file, run: + +```bash +yarn turbo test -- login +``` + +The above command will only run tests in the file or files that match the provided string. + +You can also run the matching tests from above in watch mode by running: + +```bash +yarn turbo test:watch -- login.test +``` + +To generate a `coverage` report, run: + +```bash +yarn turbo coverage +``` + +By default, `turbo` will cache test runs. This means that re-running tests wihout changing any of the related files will return the cached logs from the last run. To bypass the cache, run tests with the `force` flag, as follows: + +```bash +yarn turbo test --force +``` ### Linking the framework diff --git a/packages/apps/esm-devtools-app/package.json b/packages/apps/esm-devtools-app/package.json index f978b3505..2bee017df 100644 --- a/packages/apps/esm-devtools-app/package.json +++ b/packages/apps/esm-devtools-app/package.json @@ -10,7 +10,8 @@ "start": "openmrs develop", "serve": "webpack serve --mode=development", "debug": "npm run serve", - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode=development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/apps/esm-implementer-tools-app/package.json b/packages/apps/esm-implementer-tools-app/package.json index e9860417b..d30ebbeb7 100644 --- a/packages/apps/esm-implementer-tools-app/package.json +++ b/packages/apps/esm-implementer-tools-app/package.json @@ -10,7 +10,8 @@ "start": "openmrs develop", "serve": "webpack serve --mode=development", "debug": "npm run serve", - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode=development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/apps/esm-login-app/package.json b/packages/apps/esm-login-app/package.json index 16f6f63b1..efcf890d0 100644 --- a/packages/apps/esm-login-app/package.json +++ b/packages/apps/esm-login-app/package.json @@ -10,7 +10,8 @@ "start": "openmrs develop", "serve": "webpack serve --mode=development", "debug": "npm run serve", - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode=development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/apps/esm-offline-tools-app/package.json b/packages/apps/esm-offline-tools-app/package.json index 16a27232a..1801ce200 100644 --- a/packages/apps/esm-offline-tools-app/package.json +++ b/packages/apps/esm-offline-tools-app/package.json @@ -10,7 +10,8 @@ "start": "openmrs develop", "serve": "webpack serve --mode=development", "debug": "npm run serve", - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode=development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/apps/esm-primary-navigation-app/package.json b/packages/apps/esm-primary-navigation-app/package.json index 6b0e23636..400c62cfb 100644 --- a/packages/apps/esm-primary-navigation-app/package.json +++ b/packages/apps/esm-primary-navigation-app/package.json @@ -10,7 +10,8 @@ "start": "openmrs develop", "serve": "webpack serve --mode=development", "debug": "npm run serve", - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode=development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/framework/esm-api/package.json b/packages/framework/esm-api/package.json index 5a85e2f5e..e9d6676a1 100644 --- a/packages/framework/esm-api/package.json +++ b/packages/framework/esm-api/package.json @@ -7,7 +7,8 @@ "main": "src/index.ts", "source": true, "scripts": { - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/framework/esm-breadcrumbs/package.json b/packages/framework/esm-breadcrumbs/package.json index fb7095960..f7731e269 100644 --- a/packages/framework/esm-breadcrumbs/package.json +++ b/packages/framework/esm-breadcrumbs/package.json @@ -7,7 +7,8 @@ "main": "src/index.ts", "source": true, "scripts": { - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/framework/esm-config/package.json b/packages/framework/esm-config/package.json index 2a168983b..e1f7804bf 100644 --- a/packages/framework/esm-config/package.json +++ b/packages/framework/esm-config/package.json @@ -7,7 +7,8 @@ "main": "src/index.ts", "source": true, "scripts": { - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/framework/esm-dynamic-loading/package.json b/packages/framework/esm-dynamic-loading/package.json index cea09b569..44a358530 100644 --- a/packages/framework/esm-dynamic-loading/package.json +++ b/packages/framework/esm-dynamic-loading/package.json @@ -8,7 +8,8 @@ "source": true, "sideEffects": false, "scripts": { - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/framework/esm-extensions/package.json b/packages/framework/esm-extensions/package.json index 16bbbaa80..02f38da77 100644 --- a/packages/framework/esm-extensions/package.json +++ b/packages/framework/esm-extensions/package.json @@ -7,7 +7,8 @@ "main": "src/index.ts", "source": true, "scripts": { - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/framework/esm-feature-flags/package.json b/packages/framework/esm-feature-flags/package.json index 8d4d88b91..971d17737 100644 --- a/packages/framework/esm-feature-flags/package.json +++ b/packages/framework/esm-feature-flags/package.json @@ -7,7 +7,8 @@ "main": "src/index.ts", "source": true, "scripts": { - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/framework/esm-framework/package.json b/packages/framework/esm-framework/package.json index 757b1e962..fd0dea7b8 100644 --- a/packages/framework/esm-framework/package.json +++ b/packages/framework/esm-framework/package.json @@ -7,7 +7,8 @@ "source": true, "scripts": { "document": "../../../document.sh esm-framework", - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/framework/esm-offline/package.json b/packages/framework/esm-offline/package.json index 7a389a309..fb14058af 100644 --- a/packages/framework/esm-offline/package.json +++ b/packages/framework/esm-offline/package.json @@ -7,7 +7,8 @@ "main": "src/index.ts", "source": true, "scripts": { - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/framework/esm-state/package.json b/packages/framework/esm-state/package.json index dcb96f94e..e6fcaa2e9 100644 --- a/packages/framework/esm-state/package.json +++ b/packages/framework/esm-state/package.json @@ -7,7 +7,8 @@ "main": "src/index.ts", "source": true, "scripts": { - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/packages/framework/esm-styleguide/package.json b/packages/framework/esm-styleguide/package.json index 41fab61e7..75606def6 100644 --- a/packages/framework/esm-styleguide/package.json +++ b/packages/framework/esm-styleguide/package.json @@ -7,7 +7,8 @@ "main": "src/index.ts", "source": true, "scripts": { - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "start:storybook": "start-storybook --port 7000", "build:storybook": "build-storybook", "build": "webpack --mode=production", diff --git a/packages/framework/esm-utils/package.json b/packages/framework/esm-utils/package.json index 6761497c0..f53cc3aad 100644 --- a/packages/framework/esm-utils/package.json +++ b/packages/framework/esm-utils/package.json @@ -8,7 +8,8 @@ "source": true, "sideEffects": false, "scripts": { - "test": "jest --config jest.config.js --passWithNoTests", + "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color", + "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color", "build": "webpack --mode=production", "build:development": "webpack --mode development", "analyze": "webpack --mode=production --env analyze=true", diff --git a/turbo.json b/turbo.json index 7b1ddefde..ffc1e330e 100644 --- a/turbo.json +++ b/turbo.json @@ -9,27 +9,15 @@ "dependsOn": ["^build:development"], "outputs": ["dist/**"] }, - "test": { - "dependsOn": [], - "outputs": [] - }, - "watch": { - "dependsOn": [], - "outputs": [] - }, + "test": {}, + "test:watch": {}, + "watch": {}, "lint": { - "dependsOn": ["^lint"], - "outputs": [] + "dependsOn": ["^lint"] }, "typescript": { - "dependsOn": ["^typescript"], - "outputs": [] - }, - "extract-translations": { - "outputs": [] + "dependsOn": ["^typescript"] }, - "dev": { - "cache": false - } + "extract-translations": {} } }