Skip to content

Handler Testing #85

@samhstn

Description

@samhstn

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions