Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ai-docs/patterns/testing-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment on lines +217 to +221

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the new-widget template test script

This new testing convention doesn't update the code-generation template: ai-docs/templates/new-widget/02-code-generation.md:675 still emits tsc --project tsconfig.test.json && jest --coverage. New contact-center widgets generated from that template will therefore be the only packages without the NODE_ENV=test guard, so running their generated test:unit in a CI pod with ambient NODE_ENV=production will reintroduce the React act(...) production-build failure described here.

Useful? React with 👍 / 👎.


**Where it appears**
- Root `package.json` `scripts` block (`test:unit`, `test:cc-widgets`, `test:e2e`, `test:styles`, `test:tooling`, `test:meetings-widget`).

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/@webex/widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
2 changes: 1 addition & 1 deletion packages/contact-center/cc-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/contact-center/cc-digital-channels/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/contact-center/cc-widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/contact-center/station-login/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/contact-center/store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the store spec for the pinned test command

Changing this package script leaves the module's own spec stale: packages/contact-center/store/ai-docs/store-spec.md:47 still states the command is tsc --project tsconfig.test.json && jest --coverage even though the code now relies on pinning NODE_ENV=test to avoid React production builds. Anyone following the store spec for a single-package run in a CI pod with NODE_ENV=production can reproduce the failure this patch is trying to eliminate, so the spec needs the same command update.

AGENTS.md reference: AGENTS.md:L68-L68

Useful? React with 👍 / 👎.

"test:styles": "eslint",
"deploy:npm": "yarn npm publish"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/contact-center/task/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/contact-center/ui-logging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/contact-center/user-state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Loading