I have a simple REST API that allows to POST resources in a given endpoint, and I want to validate that the response headers are set correctly. I have defined the following feature, which inserts a bunch of users in the database:
Scenario Outline: Creating a bunch of new users when the database is empty
Given header Content-Type = 'application/json'
And request __row
When method post
Then status 201
* match header Content-Type == 'application/json'
* match header Location == 'http://localhost:8080/users/'+response.id
Examples:
| users |
Users are inserted correctly, and in console I can see the following response headers:
1 < 201
1 < Connection: keep-alive
1 < Content-Type: application/json
1 < Date: Mon, 22 Feb 2021 14:06:31 GMT
1 < Keep-Alive: timeout=60
1 < Location: http://localhost:8080/users/user1@test.com
1 < Transfer-Encoding: chunked
But each time I try to run this test, I get the same response:
path: $['Content-Type'][0], actual: null, expected: 'application/json', reason: actual json-path does not exist
Aucun commentaire:
Enregistrer un commentaire