Closed ywett02 closed 7 years ago
@ywett02 Thanks! This looks like bug for sure. First, there's the Gavel.js error:
Gavel.js validation errored: TypeError: invalid media type
It's probably caused by something in your apiary.apib
file. Is it possible for you to disclose contents of the file or at least a relevant part of it, anonymized?
When the Gavel.js error happens, Dredd isn't able to recover, gracefully report the error and abort testing, but crashes on
/usr/local/lib/node_modules/dredd/lib/transaction-runner.js:638
this.emitError(isValidError, test);
^
TypeError: this.emitError is not a function
That's definitely a bug.
@honzajavorek I sent you email with details of our apiary.apib file.
I was able to reproduce the problem with given API Blueprint. I've ran the latest Dredd (3.0.0) like this:
dredd apiary.apib http://google.com --level=silly
I've got the same output as @ywett02 reported above. In the output, following part is the most important:
verbose: Processing transaction #26: Instructors > Instructor photo > Get photo of instructor
verbose: Running 'beforeEach' hooks
debug: Running hooks...
verbose: Running 'before' hooks
debug: Emitting to reporters: test start
verbose: About to perform an HTTP request to tested server
verbose: Handling HTTP response from tested server
silly: Recieving some data from tested server
silly: Recieving some data from tested server
silly: Recieving some data from tested server
debug: Response from tested server was recieved
verbose: Running 'beforeEachValidation' hooks
debug: Running hooks...
verbose: Running 'beforeValidation' hooks
verbose: Validating HTTP transaction by Gavel.js
debug: Determining whether HTTP transaction is valid (getting boolean verdict)
debug: Gavel.js validation errored: TypeError: invalid media type
From the first line it's possible to see the problem is in the Instructors > Instructor photo > Get photo of instructor
transaction. The relevant part of the API Blueprint looks like this:
### Get photo of instructor [GET]
Returns photo of instructor of given **id**. Real image data is returned, usually in jpeg format. Additional request attributes can be used to retrieve the image with specific width and height.
Default (phantom) picture is returned in case the instructor has no photo set.
+ Request (application/json)
+ Headers
Authorization: Bearer xyz
+ Response 200 (image)
The output from Gavel isn't very helpful (it doesn't mention the invalid media type value), but from the API Blueprint it's possible to see the input: image
. However, image
isn't a valid media type. If you want to test this endpoint, you may need to change the API Blueprint to something like this:
+ Request (application/json)
+ Headers
Authorization: Bearer xyz
+ Response 200 (image/png)
+ Response 200 (image/gif)
+ Response 200 (image/jpeg)
Basically, you want to list all possible image formats your API supports in the response and which user of your API can expect.
The problem is, Dredd has some problems with testing binary endpoints: https://github.com/apiaryio/dredd/issues/87 So you may want to completely avoid testing this endpoint at the moment. To do that, you can use hooks to skip this particular transaction.
To sum it up, you should:
I should:
I filed https://github.com/apiaryio/dredd/issues/731 and https://github.com/apiaryio/gavel.js/issues/88 as follow-ups. @ywett02 Thank you very much for filing this issue and drawing attention to these problems! 👍 I hope this helped!
Describe your problem
After test fails, dredd stops with following error:
What command line options do you use?
What is in your
dredd.yml
?What's your
dredd --version
output?Does
dredd --level=debug
uncover something?