summaryrefslogtreecommitdiff
path: root/async/features/steps/request.js
blob: 99e747639279c43415f3ab3271dcc175f27eb6cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Given, When, Then } from '@cucumber/cucumber'
import assert from 'node:assert/strict'
import axios from 'axios'

When('I request the same resource three times', function () {
  const url = 'http://localhost:8080/'

  return axios.request(url)
    .then(res => {
      this.first = res.data

      return axios.request(url)
    }).then(res => {
      this.second = res.data

      return axios.request(url)
    }).then(res => {
      this.third = res.data
    })
})

Then('the responses should be the same', function () {
  assert.equal(this.first, this.second)

  if (this.third === undefined) {
    return
  }
  assert.equal(this.second, this.third)
})