Feature: Test API response status codesScenario Outline: Test API response for status codes Given I send a GET request to "<endpoint>"Then the response status code should be <status_code>Examples: | endpoint | status_code | | /api/users | 200 | | /api/users/123 | 404 | | /api/products | 200 | | /api/products/456 | 404 |
const{Given,Then}=require('cucumber');const{expect}=require('chai');constrequest=require('supertest');letapp;Given('I send a GET request to {string}',asyncfunction(endpoint){app=require('../app');this.response=awaitrequest(app).get(endpoint);});Then('the response status code should be {string}',function(statusCode){expect(this.response.status).to.equal(parseInt(statusCode));});
{"scripts":{"test":"cucumber-js"}}
stages:
- test
test:
image: node:latest
stage: test
script:
- npm install
- npm run test
artifacts:
paths:
- cucumber_report/