Does not work with browserify
See original GitHub issueNock 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:
- Created 10 years ago
- Comments:50 (11 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@JuHwon @miazoom @choonkending I’ve been trying to test my
axios
clients withkarma
andphantomjs
usingnock
but had 0 success. The client is still hitting the real server. Anyone got around it?@miazoom @choonkending having the same issue while following the redux test examples from the doc. Did you solve this?