visionmedia / expresso

use mocha
http://visionmedia.github.com/expresso
759 stars 89 forks source link

assert.response. second request after response #155

Open zxcabs opened 12 years ago

zxcabs commented 12 years ago

node v0.6.1 expresso v0.9.2

Hi, How i can do second request using data from first response?

For example, on expresso v0.8.1, i can do this as:

assert.response(server, {
      url: '/',
      method: 'GET'
    }, {
      body: 'Hello World\n',
      status: 200,
      headers: {'Content-Type': 'text/plain'}
   }, function (res) {
      //now i can use res for second request
     assert.response(server, { url: '/foo', data: res.body }, ....); 
});

But, on expresso v0.9.2 this code drop error:

uncaught undefined: Error: connect ECONNREFUSED
at errnoException (net.js:614:11)
at Object.afterConnect [as oncomplete] (net.js:605:18)

So, how can i do it?

gitfy commented 12 years ago

Yes, this problem came after upgrading to node 0.6.1, it wasn't there before that. The same version was running fine with node 0.4.2.

zxcabs commented 12 years ago

And so, what can me do? Return to node v0.4.x or waiting fix?

emostar commented 12 years ago

Ant idea when expresso will support node 0.6?

nmcclay commented 12 years ago

I'm adding a plus one to this, I really would like to be able to write more than one assert.response for a given test.

Zenedith commented 12 years ago

Any news?

emostar commented 12 years ago

I would say, switch to mocha... that is what I did.

There is no assert.response in mocha, but you can include a http library that will do the same thing. I can send you a gist if want to see how I did it.

Zenedith commented 12 years ago

Thank you for your advice - I will be grateful for gist.

Zenedith commented 12 years ago

That's my solution - pretty fast switching! https://gist.github.com/3024952