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

Handler Testing #85

Open
samhstn opened this issue Nov 14, 2016 · 1 comment
Open

Handler Testing #85

samhstn opened this issue Nov 14, 2016 · 1 comment
Assignees

Comments

@samhstn
Copy link

samhstn commented Nov 14, 2016

At the moment you are testing the string that gets returned out of the handler function in src/handler.js

I don't think this is a good practice.

I would say a better test would be to test what data the response.end(data) is called on

Something like:

tape('handler', function (t) {
  handler({ url: '/' }, {
  writeHead: function (status, obj) { 
    t.equal(status, 200);
    t.equal(obj, ...);
  },
  end: function (data) {
    t.equal(data, ...);
  }
}
}

I'm not sure if that will work, but something similar to that

@tbtommyb
Copy link
Contributor

Good idea. I think we were trying to test the handler function without mocking the server but your approach makes far more sense.

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

2 participants