0

I'm making an API call and want to verify that it succeeded. Something like this:

var response = await api.ensureSettings(data);

expect(response.code).toBe(200);

How can I check equivalence in codeceptjs?

NDavis
  • 917
  • 1
  • 11
  • 20

2 Answers2

1

You can use it with chai http://chaijs.com/. After install chai just do:

var expect = require('chai').expect;

on top of your test script, than you can use

expect(response.code).to.be.equal(200);

I recommend you use postman/newman to testing your Api, but you could do it too with codeceptjs.

Renan Lira
  • 116
  • 2
  • 4
0

you have to use additional libraries either codeceptjs chai or codeceptjs assert library

"codeceptjs-assert": "0.0.4", "codeceptjs-chai": "^1.0.0",

I.assertStrictEqual(response.code, 200)