I have written a simple Express app. I am trying out Karate for API Testing, when I try to get a certain endpoint (literally GET) im expecting a response of status code 200 and the json test data for that endpoint. However, I am getting a 426 instead.
Here is the karate feature file
Feature: Test
Background:
* url http://localhost:3000
Scenario: Read users
Given path users
And header Upgrade = HTTP/1.0
And header Connection = Upgrade
And header Accept = application/json
And header Accept-Encoding = gzip, deflate
And header Connection = keep-alive
When method get
Then status 200
* print response
* print response.headers
I only have one dependency in pom.xml:
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>1.4.1.RC2</version>
<scope>test</scope>
</dependency>
The express app:
const port = 3000
var testData = [
{
"name": "John Mayer",
"info": {
"title": "Mr.",
"age": "35",
"phone": "23423423-23423",
"email": "jmayer@test.com"
},
"id":"old001"
}
]
app.listen(port, () => {
console.log(`Server listening on port ${port}`)
})
app.get( /users , (req, res) => {
console.log(req.protocol)
res.status(200).send(testData)
})
When I try this with Postman I get a 200 and the expected json test data.
I tried adding the Upgrade and Connection headers in the Karate feature too but I m still getting a 426 status code.