1

Any Idea how the rest api error codes can be tested with Dredd in combination with swagger .yaml file?

Is there a best practice how to test all the different errors for the paths?

Example:

Path /task/{id} can have 3 type of responses: 
200 -> OK
404 -> Task not found 
403 -> Forbidden(not your task)

Is it possible to test all 3 "workflows" for this path with swagger / dredd?

ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122
Waldemar
  • 105
  • 1
  • 11

1 Answers1

0

It is possible with hooks. See the Choosing HTTP Transactions and Multiple Requests and Responses sections in Dredd's docs:

When using OpenAPI 2 format, by default Dredd tests only responses with 2xx status codes. Responses with other codes are marked as skipped and can be activated in hooks:

var hooks = require('hooks');

hooks.before('/resource > GET > 500 > application/json', function (transaction, done) {
  transaction.skip = false;
  done();
});
Honza Javorek
  • 8,566
  • 8
  • 47
  • 66