Created
May 28, 2012 21:11
-
-
Save No9/2821229 to your computer and use it in GitHub Desktop.
A sample implementation of trumpet in nodejistsu http-proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'), | |
httpProxy = require('http-proxy'), | |
trumpet = require('trumpet'); | |
httpProxy.createServer( | |
function (req, res, next) { | |
var _write = res.write; | |
res.write = function (data) { | |
var tr = trumpet(); | |
tr.select('.b', function (node) { | |
node.replace(function (html) { | |
return '<div>& Trumpet</div>'; | |
}); | |
}); | |
tr.on('data', function (buf) { | |
_write.call(res, buf); | |
}); | |
tr.write(data); | |
} | |
next(); | |
}, | |
9000, 'localhost' | |
).listen(8000); | |
http.createServer(function (req, res) { | |
res.writeHead(200, { 'Content-Type': 'text/html' }); | |
res.write('<html><head></head><body><div class="a">Nodejitsu Http Proxy</div><div class="b">& Frames</div></body></html>'); | |
res.end(); | |
}).listen(9000); |
dominictarr
commented
May 30, 2012
via email
oh yeah, eventually I got annoyed with tap and pretty much went back
to no test framework too.
as long as it exits non zero on a failure then you can use it
automatically, that is the bare minimum.
oh yeah, if your running `tap test/test.js` I think if you don't call
t.end() tap will hang, but you can also run tap tests just with `node
test/test.js` and it will only run the tests and output the TAP
protocol messages, so it shouldn't hang.
cheers, Dominic
…On Wed, May 30, 2012 at 10:35 AM, Anton Whalley ***@***.*** wrote:
Thanks @dominictarr
I tried hard to get tap up and running even followed @isaacs very detailed sample.
https://github.com/isaacs/node-tap/blob/master/example/test/test-example.js
I got the plans and test http server up no problems but I couldn't prevent http-proxy hanging :(
I tried it without my middleware even killing the process when the tests had complete and all sorts of shenanigans in between but to no avail.
So I have resorted back to plain old assert and I am happy.
Anyway onto making some funky samples to test out some use cases.
Thanks Again
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/2821229
@dominictarr "you can also run tap tests just with node test/test.js
" interesting - I didn't try that.
Given the fact you had a similar outcome I think I will stick where I am for now.
TTFN
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment