I am unable to use the GET,POST,PUT any http request when I am using the cucumber with playwright. In the step definition I am trying to use the request.get but it says not a function. when I create a new context I can do all the operation how to use the playwright config in cucumber for API testing
Given("I hit the endpoint {string}", async (request) => {
const response = await request.get("/metrics", {
headers: {
Authorization: auth_token,
},
});
console.log(response);
});
when I create a new context I am able to send request
const context = await request.newContext({
baseURL: 'https://habitat-energy-development.eu.auth0.com/'
});
const response = await context.post('/oauth/token',{
headers: {
"Accept": 'application/vnd.github.v3+json',
},
data: {
"grant_type": "password,
"username":'',
"password":'',
"client_id": '',
"client_secret": '',
"audience":
}
});
expect(response.ok()).toBeTruthy();`