Skip to content

feat: allow spy warning and return emitted state - #144

Open
climba03003 wants to merge 4 commits into
mainfrom
feat/spy
Open

feat: allow spy warning and return emitted state#144
climba03003 wants to merge 4 commits into
mainfrom
feat/spy

Conversation

@climba03003

Copy link
Copy Markdown
Member

Fixes fastify/fastify#6878

  1. Return the current emitted state when warning is called.
  2. Allows spy the warning

No performance is dropped for adding the spy feature.

# Feature Branch
process-warning> node .\benchmarks\warn.js
warn x 188,557,324 ops/sec ±3.67% (89 runs sampled)
(node:36000) [TST_ERROR_CODE_1] TestWarning: message
(Use `node --trace-warnings ...` to show where the warning was created)
(node:36000) [TST_ERROR_CODE_2] TestWarning: message

# Main Branch
process-warning> node .\benchmarks\warn.js
warn x 185,718,346 ops/sec ±3.11% (86 runs sampled)
(node:39960) [TST_ERROR_CODE_1] TestWarning: message
(Use `node --trace-warnings ...` to show where the warning was created)
(node:39960) [TST_ERROR_CODE_2] TestWarning: message

Checklist

@climba03003
climba03003 requested a review from a team July 29, 2026 12:57
Comment thread index.js Outdated
@climba03003
climba03003 requested a review from Tony133 July 29, 2026 14:01

@Tony133 Tony133 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

Comment thread README.md
console.log(spyData.callCount()) // 1
t.assert.strictEqual(spyData.callCount(), 1)

// reset the spy stat and warning state

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would try to improve the English a little bit for the doc.
@Fdawgs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Document (it's developer) and English (non native language) really not my strength.
Welcome for improvement.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not my strength either, this is why I pinged FDawgs

@Tony133
Tony133 requested a review from Fdawgs July 29, 2026 14:39
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.

Add a warning spy utility for Fastify tests

3 participants