用于 API 测试的 Codeceptjs - Node.js
Codeceptjs for API testing - Node.js
如题所述,我想用Codeceptjs测试一个API。
我的问题是,我的系统能够接收我作为请求发送的 JSON,但我认为它不知道 运行 是什么。我的直觉是它与 URL.
有关
这是我的 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"
}
这是一个文件名为 '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));
});
有线索吗?我是 codeceptjs 的新手,所以请原谅。提前致谢。
我明白了。问题是端点以斜杠 ('\') 结尾,url 以斜杠 ('\') 开头。
现在一切正常。
如题所述,我想用Codeceptjs测试一个API。 我的问题是,我的系统能够接收我作为请求发送的 JSON,但我认为它不知道 运行 是什么。我的直觉是它与 URL.
有关这是我的 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"
}
这是一个文件名为 '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));
});
有线索吗?我是 codeceptjs 的新手,所以请原谅。提前致谢。
我明白了。问题是端点以斜杠 ('\') 结尾,url 以斜杠 ('\') 开头。
现在一切正常。