Skip to content
Snippets Groups Projects
Commit 59c00aa6 authored by Ole Langbehn's avatar Ole Langbehn
Browse files

Revert "forgot to add smoketest directory"

This reverts commit d63b64c2.
parent d63b64c2
No related branches found
No related tags found
No related merge requests found
import http from 'k6/http'
import { check, sleep } from 'k6'
// You don't need to change anything in this section, it's k6 glue code.
// See the default function at the end of the file for defining your smoketest.
// This configuration only executes 1 test, enough for a smoketest. The smoketest will fail on any check failing.
const allChecksNeedToPassTreshold = { checks: [{ threshold: 'rate==1', abortOnFail: true }] }
export const options = {
vus: 1,
iterations: 1,
thresholds: allChecksNeedToPassTreshold,
}
/**
* Performs a GraphQL query and checks the response using the provided function. Fails if any of the provided expectations are not met.
* @param {string} query The GraphQL query to perform
* @param {(response: http.Response) => Array<boolean>} checkFunction
* A function that takes the HTTP response as an argument and returns an array
* of boolean values, each indicating success or failure of a test.
*/
function forQuery(query, checkFunction) {
const response = http.post(`${__ENV.BASE_URL}`, JSON.stringify({ query }), {
headers: { 'Content-Type': 'application/json' },
})
checkFunction(response)
}
// Define your smoketest(s) here.
export default () => {
forQuery(`{placeDetails(id:"51223999b85500244059f052ea9271c64a40f00101f9013ef5000000000000c00208"){name}}`, (response) => {
check(response, {
'is status 200': (r) => r.status === 200,
})
check(JSON.parse(response.body), {
// there can be multiple tests here, e.g.
//"contains topics object": (r) => typeof r.data.topics != null,
'returns name for place': (r) => typeof r.data.placeDetails.name === "string",
})
})
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment