Skip to content

test(eio-parser): assert the decoded payload in the binary stream tests - #5586

Merged
darrachequesne merged 1 commit into
socketio:mainfrom
dylanpulver:test/assert-decoded-binary-payload
Nov 5, 2026
Merged

darrachequesne merged 1 commit into
socketio:mainfrom
dylanpulver:test/assert-decoded-binary-payload

Conversation

@dylanpulver

Copy link
Copy Markdown
Contributor

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other (a test fix)

Current behavior

Three assertions in packages/engine.io-parser/test/index.ts have no matcher, so the comparison is
evaluated and thrown away:

expect(areArraysEqual(value.data, payload));

They are in should decode a binary packet (ArrayBuffer) at the small, medium and big sizes. Each of
those tests checks the packet type and that the data is an ArrayBuffer, but nothing checks that the
decoded bytes match what was written, which is what the test names describe. decodePacket could
return a buffer of the right length and wrong contents and all three would still pass.

The five other areArraysEqual assertions in these files already use .to.be(true), including the
one added in #5583.

New behavior

The three assertions use .to.be(true), matching their neighbours.

Other information (e.g. related issues)

npm run test:node in packages/engine.io-parser: 33 passing before and after, so the payloads do
round-trip correctly today. Replacing the three new matchers with .to.be(false) gives 30 passing
and 3 failing, so they do assert. npm run format:check reports no changes.

Three assertions in the packet decoder stream tests had no matcher, so the
comparison was evaluated and discarded:

    expect(areArraysEqual(value.data, payload));

Those tests checked the packet type and that the data was an ArrayBuffer, but
never that the decoded bytes matched what was written, which is what the test
names describe. The five other `areArraysEqual` assertions in these files, one
of them added in socketio#5583, already use `.to.be(true)`.
@darrachequesne
darrachequesne merged commit 111e378 into socketio:main Nov 5, 2026
10 checks passed
@darrachequesne

Copy link
Copy Markdown
Member

Good catch, thanks 👍

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