Skip to content

fix(tooling): pin NODE_ENV=test on jest invocations#724

Merged
bhabalan merged 2 commits into
webex:nextfrom
bhabalan:fix/test-node-env
Jul 22, 2026
Merged

fix(tooling): pin NODE_ENV=test on jest invocations#724
bhabalan merged 2 commits into
webex:nextfrom
bhabalan:fix/test-node-env

Conversation

@bhabalan

Copy link
Copy Markdown
Contributor

COMPLETES #< INSERT LINK TO ISSUE >

This pull request addresses

Unit tests fail in CI/pod environments that already export NODE_ENV=production. Jest only defaults NODE_ENV to test when it is unset; when the ambient environment already sets NODE_ENV=production, Jest inherits it, React loads its production build, and act(...) throws:

act(...) is not supported in production builds of React

This failed 24 @webex/cc-user-state tests (and is latent for every other package). The test commands in the manifest and docs only specified the bare yarn test:cc-widgets / yarn workspace @webex/{pkg} test:unit, none of which pinned NODE_ENV, so the repository contract did not account for running inside a pod with NODE_ENV=production.

by making the following changes

Pin NODE_ENV=test directly on the jest invocation at the source, so it is correct regardless of the ambient environment and regardless of which invocation path is used (single-package, test:cc-widgets, or the aggregate test:unit):

  • Root package.json: test:tooling.
  • Every package test:unit that runs jest: store, cc-components, cc-widgets, cc-digital-channels, user-state, task, station-login, ui-logging, and meetings @webex/widgets.
  • Documented the rationale in ai-docs/patterns/testing-patterns.md.

Follows the repo's existing inline-env convention (build:dev / build:prod in root package.json); cross-env is not a workspace dependency. The .sdd/manifest.json command stays as the bare yarn test:cc-widgets since the fix is now at the source.

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

  • The testing is done with the amplify link
  • Reproduced the failure: NODE_ENV=production yarn workspace @webex/cc-user-state test:unit failed with act(...) is not supported in production builds of React before the change.
  • After the change, the same command passes (24/24 tests).
  • Ran the full pre-commit suite with the ambient failure condition: NODE_ENV=production yarn run test:unit → exit 0, all suites pass, zero not supported in production builds errors.
  • Pre-commit hook (full test:unit + test:styles) passed on commit.

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was used to create a draft that was subsequently customized or modified
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Please Specify: Claude Code
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

Checklist before merging

  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the testing document
  • I have tested the functionality with amplify link

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),
failing the 24 @webex/cc-user-state tests among others.

Pin NODE_ENV=test on every jest invocation (each package's test:unit and
the root test:tooling) so tests are correct regardless of the ambient
environment, covering all invocation paths (single-package,
test:cc-widgets, and the aggregate test:unit). Document the rationale in
testing-patterns.md.
@aws-amplify-us-east-2

Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-724.d1b38q61t1z947.amplifyapp.com

@bhabalan
bhabalan marked this pull request as ready for review July 22, 2026 06:39
@bhabalan
bhabalan requested a review from a team as a code owner July 22, 2026 06:39

@mkesavan13 mkesavan13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me. Thanks, Bharath

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab6b5aa9b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +217 to +221
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.

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 👍 / 👎.

"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 👍 / 👎.

@bhabalan bhabalan added the validated Indicates that the PR is ready for actions label Jul 22, 2026
@bhabalan
bhabalan enabled auto-merge (squash) July 22, 2026 10:23
@github-actions github-actions Bot removed the validated Indicates that the PR is ready for actions label Jul 22, 2026
@akulakum akulakum added the validated Indicates that the PR is ready for actions label Jul 22, 2026
@bhabalan
bhabalan merged commit d29c8ec into webex:next Jul 22, 2026
7 checks passed
@github-actions

Copy link
Copy Markdown
🎉 Your changes are now available!
Released in: webex-widgets-v1.28.2-next.9, webex-cc-widgets-v1.28.0-next.48
📖 View full changelog →
Packages Updated Version
@webex/cc-widgets 1.28.0-next.48
@webex/widgets 1.28.2-next.9
@webex/cc-components 1.28.0-next.38
@webex/cc-digital-channels 0.0.0-next.19
@webex/cc-station-login 1.28.0-next.38
@webex/cc-store 1.28.0-next.23
@webex/cc-task 1.28.0-next.41
@webex/cc-ui-logging 1.28.0-next.24
@webex/cc-user-state 1.28.0-next.39
@webex/test-fixtures 0.0.0-next.1
samples-cc-react-app 0.0.0-next.1
samples-cc-wc-app 0.0.0-next.1
samples-meeting-app 0.0.0-next.1

Thank you for your contribution!
🤖 This is an automated message. For queries, please contact support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

validated Indicates that the PR is ready for actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants