question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

expect(Buffer).to.be.a('Buffer') incorrectly fails

See original GitHub issue

As on tin, but best explained by example:

Test case:

	it('should be a buffer', () => {
		let buf = Buffer.alloc(0)

		expect(buf).to.be.a('buffer')
	})

result:

     AssertionError: expected <Buffer > to be a buffer

env is a linux system, with the following:

$ node -v
v8.4.0
$ npm ls | grep chai
├─┬ chai@4.1.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

18reactions
vieiralucascommented, Sep 11, 2017

@damianb btw you can workaround this by using the instanceof assertion

const buf = Buffer.alloc(0)
expect(buf).to.be.instanceof(Buffer)
1reaction
damianbcommented, Sep 11, 2017

@vieiralucas Thanks - ended up picking out that workaround myself after a little head scratching.

Figured it was worth still having the issue open, however - not sure if it merits further looking at, but that’s your team’s call.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to clean up the previous expect_buf in an expect script
I've determined empirically that unsetting the expect_out(buffer) is much more consistent than "expect *". This post was of great help for me.
Read more >
What is a Buffer Overflow | Attack Types and Prevention Methods
Attackers exploit buffer overflow issues to change execution paths, triggering responses that can damage the applications and exposes private information.
Read more >
Buffer Solutions - Cal State LA
Buffer Solutions ν Let's go back to problem of adding HCl to buffer solution: ν We can use H-H eqn. to make the...
Read more >
Buffer Overflow Vulnerabilities, Exploits & Attacks - Veracode
Common application development mistakes that can lead to buffer overflow include failing to allocate large enough buffers and neglecting to check for overflow ......
Read more >
Buffers
A buffer system can be made by mixing a soluble compound that contains the conjugate ... Although this step is not truly necessary...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found