Skip to content

Upgrade to mocha 12#4

Merged
GrahamCampbell merged 2 commits intomainfrom
mocha-upgrade
Apr 22, 2026
Merged

Upgrade to mocha 12#4
GrahamCampbell merged 2 commits intomainfrom
mocha-upgrade

Conversation

@GrahamCampbell
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the project’s test runner setup to support Mocha 12 and modernizes related runtime/test harness behavior, including Node.js version gating and more deterministic test isolation.

Changes:

  • Switch Mocha execution to a repo-level config (test/mocha/unit.cjs) with shared bootstrap + root hooks (Chai plugins, env defaults, sandboxed cwd/env, sinon restore).
  • Refactor Node logging initialization to be an explicit function (improves testability) and adjust tests accordingly.
  • Tighten Node.js support checks to a semver range and update CLI messaging, docs, and CI workflows to match.

Reviewed changes

Copilot reviewed 36 out of 39 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/unit/src/utils/serverless-utils/log-reporters/node/progress-reporter.test.js Removes per-file sinon-chai setup (now provided by global Mocha bootstrap).
test/unit/src/utils/serverless-utils/log-reporters/node.test.js Updates tests for new initializeNodeLogging({ argv, env, stdin, stdout }) API and avoids global process.env/stdout mutation.
test/unit/src/utils/aws/remote-provider.test.js Removes per-file chai-as-promised/sinon-chai setup (now global).
test/unit/src/utils/aws/get-credential-provider.test.js Removes per-file sinon-chai setup (now global).
test/unit/src/utils/aws/get-client-config.test.js Removes per-file sinon-chai setup (now global).
test/unit/src/utils/aws/from-node-provider-chain.test.js Removes per-file sinon-chai setup (now global).
test/unit/src/utils/aws/default-provider.test.js Removes per-file sinon-chai setup (now global).
test/unit/src/state/utils/get-state-bucket-region.test.js Removes per-file chai-as-promised/sinon-chai setup (now global).
test/unit/src/state/utils/get-state-bucket-name.test.js Removes per-file chai-as-promised/sinon-chai setup (now global).
test/unit/src/state/get-s3-state-storage-from-config.test.js Removes per-file sinon-chai setup (now global).
test/unit/src/state/S3StateStorage.test.js Removes per-file sinon-chai/chai-as-promised setup (now global).
test/unit/src/configuration/read.test.js Removes per-file chai-as-promised setup (now global).
test/unit/src/components-service.test.js Removes per-file chai-as-promised setup (now global).
test/unit/src/cli/is-supported-node-version.test.js Updates unit tests for new semver-based Node support range behavior.
test/unit/src/Context.test.js Small test refactor to create fresh Context instances per test.
test/unit/components/framework/index.test.js Removes redundant Chai plugin wiring and uses chai.expect.
test/unit/bin/serverless-compose.test.js Aligns expectations with new Node support messaging and runComponents(argv) signature.
test/mocha/unit.cjs Adds Mocha config file (spec, requires, timeout, node options).
test/mocha/runtime-sandbox.cjs Adds suite-wide sandbox for cwd/env/argv/EvalError state and cleanup.
test/mocha/root-hooks.cjs Adds Mocha root hooks to restore sandbox state and run sinon.restore().
test/mocha/bootstrap.cjs Centralizes chai-as-promised/sinon-chai registration and sets env defaults used by tests.
test/lib/setup/restore-env.js Removed (replaced by Mocha root hooks + runtime sandbox).
test/lib/setup/patch.js Removed (replaced by Mocha config/node options and root hooks approach).
test/lib/setup/mock-homedir.js Removed (replaced by runtime sandbox HOME/USERPROFILE handling).
test/lib/setup/mock-cwd.js Removed (replaced by runtime sandbox cwd handling).
test/lib/setup/log.js Removed (test logging behavior no longer injected via old runner patching).
src/utils/serverless-utils/log-reporters/node.js Refactors log initialization into an injectable function and returns derived state.
src/state/LocalStateStorage.js Stops using process.cwd() internally; now uses provided root for state dir.
src/index.js Moves logging setup into runComponents(argv) and passes cwd explicitly to config resolver.
src/configuration/resolve-path.js Accepts an explicit cwd parameter for better testability/control.
src/cli/is-supported-node-version.js Uses semver + exported supported range to validate Node versions.
src/Context.js Ensures root resolution handles missing root more directly; passes root into LocalStateStorage.
src/ComponentsService.js Makes local component path resolution depend on context root instead of process.cwd().
package.json Switches test command to Mocha config; bumps Mocha to a v12 beta; updates Node engine range; removes inline Mocha config block.
bin/serverless-compose Updates unsupported Node messaging and passes argv explicitly into runComponents.
README.md Updates documented Node.js requirement to the new supported range.
.gitignore Limits lockfile ignores to repo root (/package-lock.json, /yarn.lock).
.github/workflows/tests.yml Updates actions versions, cache strategy, and install command to align with no-lock installs and new Node targets.
.github/workflows/publish.yml Updates actions versions, cache strategy, and install command similarly for publishing pipeline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
@GrahamCampbell GrahamCampbell merged commit 6f8c7ff into main Apr 22, 2026
7 checks passed
@GrahamCampbell GrahamCampbell deleted the mocha-upgrade branch April 23, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants