Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Check error messages.
  • Loading branch information
niklasi committed Sep 21, 2016
commit b8ed5ee67281434959399841a42eb79d63dc71c2
2 changes: 1 addition & 1 deletion test/parallel/test-http-response-add-header-after-sent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const server = http.createServer((req, res) => {
res.write('abc')
assert.throws(() => {
res.setHeader('header2', 2);
}, Error, 'setHeader after write should throw');
}, /Can't set headers after they are sent./)
res.end()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be useful checking the error message too. 'Can\'t set headers after they are sent.'

Copy link
Contributor Author

@niklasi niklasi Sep 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went back and forth with this one. I can see why it could be useful to check the error message, but I can also see why it could be problematic. The way I see it is that the error message is an "implementation detail" and not part of the api and therefore you make the test more fragile if you test the error message. I don't think the test should fail if you change the error message, but on the other hand how do you know if it is the "right" Error? I'm not sure what the best way to do this is, in this context, and I'm more than happy to discuss this.
Btw, this is my first PR for the node-project and I really appreciate your feedback.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not wrong changing the error message is considered a breaking change so I'm +1 for also checking the error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if that's considered a breaking change then I'm also for checking the error message :-)
Thank you for the clarification. I will fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have fixed the error message check now.

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const server = http.createServer((req, res) => {
res.write('abc')
assert.throws(() => {
res.removeHeader('header2', 2);
}, Error, 'removeHeader after write should throw');
}, /Can't remove headers after they are sent/)
res.end()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check error message here too.

});

Expand Down