Skip to content

docs: modernize spies example, drop should.js#6016

Open
gaurav0107 wants to merge 1 commit into
mochajs:mainfrom
gaurav0107:docs/5445-update-spies-example
Open

docs: modernize spies example, drop should.js#6016
gaurav0107 wants to merge 1 commit into
mochajs:mainfrom
gaurav0107:docs/5445-update-spies-example

Conversation

@gaurav0107
Copy link
Copy Markdown

@gaurav0107 gaurav0107 commented May 24, 2026

PR Checklist

Overview

The Spies explainer was flagged in #5445 as recommending should.js,
which has been deprecated since 2020. On a closer read the page also
contained syntactically broken examples:

  • spy.called.should.equal.true; is a no-op (reads a property and
    drops the value); the correct should.js form would be
    spy.called.should.be.true or spy.called.should.equal(true).
  • The "without any special spy library" example claimed to use no
    library yet relied on .should.equal(...) from should.js.

This PR:

  • Switches the first example to use sinon-only assertions
    (sinon.assert.calledOnce, sinon.assert.calledWith); the page
    already uses these on the second test in the same block.
  • Switches the "no library" example to node:assert, matching the
    rest of the docs site (e.g. getting-started.mdx uses node:assert).
  • Drops the should.js mention and link from the prose.

The broader audit of should.js mentions across other docs pages
remains tracked under #5445; this PR is intentionally scoped to the
spies explainer to keep the change focused.

No library code or workflow changes.

Note: #5445 is a meta-tracking issue per the maintainer's comment,
so this PR uses fixes to satisfy the PR template format but does
not aim to fully close the broader audit.

The spies explainer recommended should.js (deprecated 2020) and used
broken syntax (`spy.called.should.equal.true` reads a property and
discards the value rather than asserting). Switch the first example to
sinon-only assertions and the "no library" example to node:assert, so
both code blocks are copy-paste runnable today.

refs mochajs#5445
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 24, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: gaurav0107 / name: gaurav0107 (c087162)

@github-actions

This comment has been minimized.

@gaurav0107 gaurav0107 marked this pull request as ready for review May 24, 2026 18:26
@mark-wiemer mark-wiemer added this to the Chores milestone Jun 2, 2026
@mark-wiemer mark-wiemer self-assigned this Jun 2, 2026
@mark-wiemer mark-wiemer added the status: needs review a maintainer should (re-)review this pull request label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs review a maintainer should (re-)review this pull request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants