As mentioned in the title, I wish to use Codeceptjs to test an API. My issue is that, my system is able to receive the JSON that I'm sending as my request, however I don't think it knows what to run. My hunch is that it has something to do with the URL.
Here is my codecept.json
{
"tests": "./*_test.js",
"timeout": 10000,
"output": "./output",
"helpers": {
"REST": {
"endpoint": "http://localhost:3001/",
"defaultHeaders": {
"Content-Type": "application/json"
}
}
},
"include": {
"I": "./steps_file.js"
},
"bootstrap": false,
"mocha": {},
"name": "testFiles2"
}
And here is a sample with the file name 'samp_test.js'
var Factory = require('rosie').Factory;
var faker = require('faker');
Feature('BackgsroundData');
Scenario('Test-BackgroundData', (I) => {
var args = {
"LAST_SYNC_DATE": "2010-01-01 10:00:00",
"CLIENT_ID" : "0000",
"BRN_CODE" : "1",
"TER_CODE" : "1",
"HASH" : "sampleHash"
};
var reqHead = {
'Accept' : 'application/json',
'User-Agent': 'Unirest Node.js',
'id' : '1'
};
I.haveRequestHeaders(reqHead);
I.sendPatchRequest('/sync/backgroundData', JSON.stringify(args));
});
Any clue? I'm new to codeceptjs so please excuse me. Thanks in advance.
I got it. The issue was the endpoint ending with a slash('\') and the url starting with a slash('\').
Now it's working perfectly.