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.

Does not work with browserify

See original GitHub issue

Nock expects http.ClientRequest to be defined; the http module that browserify supplies does not use this internal object. Since ClientRequest is an internal object not typically used in an application space, I’m filing this as a bug – just because you’re CommonJS, doesn’t mean you’re running on node 😃

The error that exposes this issue:

PhantomJS 1.9.2 (Linux) ERROR
        TypeError: 'undefined' is not an object (evaluating 'superCtor.prototype')
        at /tmp/karma-browerify.js:1740
PhantomJS 1.9.2 (Linux): Executed 0 of 0 ERROR (12.249 secs / 0 secs)

I’ve traced it down to line 161 of intercept.js.

I understand if you consider nock to be just-for-node, and that extending nock to support mocking out browserify’s http shim might be out of scope for the project. But it should probably be noted in the README.md that browserify is explicitly not supported (and, to be nice, suggest an alternative).

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:50 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
alexpanovcommented, Jun 6, 2016

@JuHwon @miazoom @choonkending I’ve been trying to test my axios clients with karma and phantomjs using nock but had 0 success. The client is still hitting the real server. Anyone got around it?

1reaction
JuHwoncommented, Jun 3, 2016

@miazoom @choonkending having the same issue while following the redux test examples from the doc. Did you solve this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Browserify does not work - why? - Stack Overflow
This will not work because a Browserify bundle is like a big module which has its own scope. It is strictly encapsulated in...
Read more >
Browserify
With Browserify you can write code that uses require in the same way that you would use it in Node. Here is a...
Read more >
Browserify Tutorial - Using require() In The Browser - YouTube
Learn how to use the require() function to import Javascript modules ... very useful plugins that can be added to Browserify to provide...
Read more >
How to work with Browserify? - Merixstudio
Short guide about Browserify and how to use it.
Read more >
Browserify - npm
Start using browserify in your project by running `npm i browserify`. There are 3186 other projects in the npm registry using browserify.
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