diff --git a/ai-docs/patterns/testing-patterns.md b/ai-docs/patterns/testing-patterns.md index 3633bc811..ce7858950 100644 --- a/ai-docs/patterns/testing-patterns.md +++ b/ai-docs/patterns/testing-patterns.md @@ -214,6 +214,12 @@ yarn test:styles # style tests across workspaces yarn workspace @webex/cc-user-state test:unit # a single package ``` +Each package's `test:unit` (and root `test:tooling`) pins `NODE_ENV=test` on the `jest` +invocation. Jest only defaults `NODE_ENV` to `test` when it is *unset*; in a CI pod that already +exports `NODE_ENV=production`, React loads its production build and `act(...)` throws +(`act(...) is not supported in production builds of React`). Pinning it keeps tests correct +regardless of the ambient environment. + **Where it appears** - Root `package.json` `scripts` block (`test:unit`, `test:cc-widgets`, `test:e2e`, `test:styles`, `test:tooling`, `test:meetings-widget`). diff --git a/package.json b/package.json index 7b97e8262..52fa13a51 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "test:unit": "yarn run test:tooling && yarn run test:cc-widgets && yarn run test:meetings-widget", "test:e2e": "yarn playwright test", "test:styles": "yarn workspaces foreach --all --exclude webex-widgets run test:styles", - "test:tooling": "jest --coverage", + "test:tooling": "NODE_ENV=test jest --coverage", "test:cc-widgets": "yarn workspaces foreach --all --exclude webex-widgets --exclude samples-cc-wc-app --exclude samples-cc-react-app run test:unit", "test:meetings-widget": "yarn workspaces foreach --all --verbose --include @webex/widgets run test:unit", "build:dev": "NODE_ENV=development yarn build", diff --git a/packages/@webex/widgets/package.json b/packages/@webex/widgets/package.json index 465b98c47..ae1212468 100644 --- a/packages/@webex/widgets/package.json +++ b/packages/@webex/widgets/package.json @@ -20,7 +20,7 @@ "release:debug": "semantic-release --debug", "release:dry-run": "semantic-release --dry-run", "start": "npm run demo:serve", - "test:unit": "jest --config jest.config.js --coverage", + "test:unit": "NODE_ENV=test jest --config jest.config.js --coverage", "test:e2e": "npm run demo:build && wdio wdio.conf.js", "test:eslint": "echo 'Broken eslint tests'", "test:eslint:broken": "eslint src/" diff --git a/packages/contact-center/cc-components/package.json b/packages/contact-center/cc-components/package.json index b4ffc878d..a6680cf4c 100644 --- a/packages/contact-center/cc-components/package.json +++ b/packages/contact-center/cc-components/package.json @@ -30,7 +30,7 @@ "build": "yarn run -T tsc", "build:src": "yarn run clean:dist && webpack", "build:watch": "webpack --watch", - "test:unit": "tsc --project tsconfig.test.json && jest --coverage", + "test:unit": "tsc --project tsconfig.test.json && NODE_ENV=test jest --coverage", "test:styles": "eslint", "deploy:npm": "yarn npm publish" }, diff --git a/packages/contact-center/cc-digital-channels/package.json b/packages/contact-center/cc-digital-channels/package.json index 32f9b81d3..bf207c9f5 100644 --- a/packages/contact-center/cc-digital-channels/package.json +++ b/packages/contact-center/cc-digital-channels/package.json @@ -18,7 +18,7 @@ "build": "yarn run -T tsc", "build:src": "yarn run clean:dist && yarn run build && webpack", "build:watch": "webpack --watch", - "test:unit": "jest --coverage", + "test:unit": "NODE_ENV=test jest --coverage", "test:styles": "eslint", "deploy:npm": "yarn npm publish" }, diff --git a/packages/contact-center/cc-widgets/package.json b/packages/contact-center/cc-widgets/package.json index c92b7c04d..2ea3210db 100644 --- a/packages/contact-center/cc-widgets/package.json +++ b/packages/contact-center/cc-widgets/package.json @@ -30,7 +30,7 @@ "build": "yarn run -T tsc", "build:src": "yarn run clean:dist && webpack", "build:watch": "webpack --watch", - "test:unit": "jest --coverage", + "test:unit": "NODE_ENV=test jest --coverage", "test:styles": "eslint", "deploy:npm": "yarn npm publish" }, diff --git a/packages/contact-center/station-login/package.json b/packages/contact-center/station-login/package.json index 38df3464a..624aa716d 100644 --- a/packages/contact-center/station-login/package.json +++ b/packages/contact-center/station-login/package.json @@ -18,7 +18,7 @@ "build": "yarn run -T tsc", "build:src": "yarn run clean:dist && webpack", "build:watch": "webpack --watch", - "test:unit": "tsc --project tsconfig.test.json && jest --coverage", + "test:unit": "tsc --project tsconfig.test.json && NODE_ENV=test jest --coverage", "test:styles": "eslint", "deploy:npm": "yarn npm publish" }, diff --git a/packages/contact-center/store/package.json b/packages/contact-center/store/package.json index 4718ab223..a113038a2 100644 --- a/packages/contact-center/store/package.json +++ b/packages/contact-center/store/package.json @@ -18,7 +18,7 @@ "build": "yarn run -T tsc", "build:src": "yarn run clean:dist && webpack", "build:watch": "webpack --watch", - "test:unit": "tsc --project tsconfig.test.json && jest --coverage", + "test:unit": "tsc --project tsconfig.test.json && NODE_ENV=test jest --coverage", "test:styles": "eslint", "deploy:npm": "yarn npm publish" }, diff --git a/packages/contact-center/task/package.json b/packages/contact-center/task/package.json index 41c1880c5..c1ae0b38f 100644 --- a/packages/contact-center/task/package.json +++ b/packages/contact-center/task/package.json @@ -18,7 +18,7 @@ "build": "yarn run -T tsc", "build:src": "yarn run clean:dist && webpack", "build:watch": "webpack --watch", - "test:unit": "tsc --project tsconfig.test.json && jest --coverage", + "test:unit": "tsc --project tsconfig.test.json && NODE_ENV=test jest --coverage", "test:styles": "eslint", "deploy:npm": "yarn npm publish" }, diff --git a/packages/contact-center/ui-logging/package.json b/packages/contact-center/ui-logging/package.json index af1debf95..4dbdb194d 100644 --- a/packages/contact-center/ui-logging/package.json +++ b/packages/contact-center/ui-logging/package.json @@ -16,7 +16,7 @@ "build:src": "webpack --mode=development", "clean": "rm -rf dist", "clean:dist": "rm -rf dist", - "test:unit": "jest --coverage", + "test:unit": "NODE_ENV=test jest --coverage", "test:styles": "echo 'No styles to test'", "deploy:npm": "yarn npm publish" }, diff --git a/packages/contact-center/user-state/package.json b/packages/contact-center/user-state/package.json index ffbb726d9..55ce2df74 100644 --- a/packages/contact-center/user-state/package.json +++ b/packages/contact-center/user-state/package.json @@ -18,7 +18,7 @@ "build": "yarn run -T tsc", "build:src": "yarn run clean:dist && webpack", "build:watch": "webpack --watch", - "test:unit": "tsc --project tsconfig.test.json && jest --coverage", + "test:unit": "tsc --project tsconfig.test.json && NODE_ENV=test jest --coverage", "test:styles": "eslint", "deploy:npm": "yarn npm publish" },