I am setting up REST-API test within my codecept testing framework which uses integrated Chai.
After checking the very basic documentation on the subject in CodeceptJS documentation I can't seem to get my test to work.
const expect = require('chai').expect;
Feature('Checkout');
Scenario('Create a customer', async I => {
const payload = ({
first_name: 'Dummy title',
last_name: 'Dummy description',
email: 'john@test.com',
locale: 'fr-CA',
billing_address[first_name]: 'John',
billing_address[last_name]: 'Doe',
billing_address[line1]: 'PO Box 9999',
billing_address[city]: 'Walnut',
billing_address[state]: 'California',
billing_address[zip]: '91789',
billing_address[country]: 'US'
})
const header = ({Content-Type: 'application/x-www-form-urlencoded'})
const res = await I.sendPostRequest('https://mytesturl-
api.com/api/',payload,header);
expect(res.code).eql(200);
});
I have put my payload and header in a variable for ease of use and readability.
But it doesn't work and keeps giving me Unexpected token [