Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Hello world example failing on comparing body #343

Closed
mypark opened this issue Jan 6, 2016 · 10 comments
Closed

Hello world example failing on comparing body #343

mypark opened this issue Jan 6, 2016 · 10 comments

Comments

@mypark
Copy link

mypark commented Jan 6, 2016

Trying the hello world example with express.js and seeing this failure in the test even though the body text/html response matches

info: Beginning Dredd testing...
fail: GET /message duration: 56ms
info: Displaying failed tests...
fail: GET /message duration: 56ms
fail: body: Real and expected data does not match.

request: 
body: 

headers: 
    User-Agent: Dredd/1.0.2 (Darwin 15.2.0; x64)

uri: /message
method: GET


expected: 
headers: 
    Content-Type: text/html; charset=utf-8

body: 
hello

statusCode: 200


actual: 
statusCode: 200
headers: 
    x-powered-by: Express
    content-type: text/html; charset=utf-8
    content-length: 5
    etag: W/"5-XUFAKrxLKna5cZ2REBfFkg"
    date: Wed, 06 Jan 2016 13:36:46 GMT
    connection: close

body: 
hello
@w-vi
Copy link
Contributor

w-vi commented Jan 6, 2016

@mypark very often there are some whitespace characters somewhere which are causing this seemingly matching responses ... there is an issue #305 on this topic already.

@mypark
Copy link
Author

mypark commented Jan 6, 2016

I checked the white space in the response and in the blueprint files, and there were no extra white spaces in the response, and none in the bluprint file. Does dredd add some white spaces after the parsing of the blueprint file?

@netmilk
Copy link
Contributor

netmilk commented Jan 11, 2016

Hey @mypark,

Would you mind trying it again with an Apiary reporter and send me the link to the report? I'll try to investigate and help you.

@mypark
Copy link
Author

mypark commented Jan 11, 2016

Ok here it is, https://app.apiary.io/mikedemo/tests/run/d1c5bd6b-ec0c-45f7-ba04-6dccbb3f5362

It looks like the diff sees an extra trailing character of some sort (space or newline? I can't tell) but the actual code itself and the response doesn't have the extra character - looking at the real and expected responses doesn't seem to show the extra character.

@mypark
Copy link
Author

mypark commented Jan 11, 2016

this is the blueprint

# GET /message
+ Response 200 (text/html; charset=utf-8)

        hello

and this is the node.js code

app.get('/message', function (req, res) {
  res.send('hello');
});

neither of which have a trailing space after the hello

@allie-wake-up
Copy link

I had a very similar issue. Added a newline to my response and it validated correctly. That may not be the greatest solution though.

@honzajavorek
Copy link
Contributor

Could #305 be related?

@honzajavorek
Copy link
Contributor

I was able to reproduce this problem. It indeed looks like some issue with whitespace. Simple response with text/plain content type doesn't pass Dredd test. If changed to something with JSON content type, it passes.

@honzajavorek
Copy link
Contributor

This is still an issue, but I decided to close duplicates.

@honzajavorek
Copy link
Contributor

I'd like to address the problem. I added a comment explaining the situation: #67 (comment) If you have any ideas, I'd be very glad to discuss possible solutions.

artem-zakharchenko pushed a commit that referenced this issue Oct 9, 2019
…6.4.0

chore(deps-dev): update eslint requirement from 6.3.0 to 6.4.0
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants