Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: Buffer is not defined [mocha.js:5833] #1558

Closed
dustinbrownman opened this issue Feb 18, 2015 · 6 comments
Closed

Uncaught ReferenceError: Buffer is not defined [mocha.js:5833] #1558

dustinbrownman opened this issue Feb 18, 2015 · 6 comments

Comments

@dustinbrownman
Copy link

Getting this error with the latest version of the mocha.js file. I'm using the browser interface. Looks like the line that causes this error was added in eab389f. I set up a dummy app demonstrate the error. Just open up spec-runner.html and open up the developer tools. Any thoughts on how to fix this? (Thanks to @clemf for finding this)

boneskull pushed a commit that referenced this issue Feb 18, 2015
fix(utils): issue #1558 + make
@callmevlad
Copy link
Contributor

Seeing the same thing. Needs to be if (typeof Buffer !== 'undefined' && ...) instead of if (Buffer && ...), though I'm still trying to track down another error (failed to require "supports-color") that's downstream from that fix.

@a8m
Copy link
Contributor

a8m commented Feb 18, 2015

Needs to be if (typeof Buffer !== 'undefined' && ...) instead of if (Buffer && ...)

why it's matter @callmevlad ?

@callmevlad
Copy link
Contributor

@a8m Browsers handle this differently than V8 in Node.js - for example, try the following in your Chrome console:

Breaks:
if (Bob) { console.info("Bob exists."); } -> Uncaught ReferenceError: Bob is not defined

Works:
if (typeof Bob !== "undefined") { console.info("Bob exists."); }

@dustinbrownman
Copy link
Author

Confirmed that this is still an issue. Updated dummy app with new mocha.js file and it's the same error, but on a different line. And @callmevlad is right, this is a browser issue. I've tested it in Chrome and Firefox and gotten the same error each time.

@a8m
Copy link
Contributor

a8m commented Feb 18, 2015

@callmevlad makes sense, thx.

@callmevlad
Copy link
Contributor

Just added a PR for this: #1560

travisjeffery pushed a commit that referenced this issue Feb 21, 2015
Fixing errors that prevent mocha.js from loading in the browser - fixes #1558
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

No branches or pull requests

3 participants