forget to wait for something async in your test issue, test were supposed to fail
amrsa1 opened this issue · comments
this test below supposed to fail
fit('Verify deleting last created table, API will return status code 200', async (done)=> { return frisby.timeout(timeout) .get('https://dev.sdsdsd.com/api/settings/user-settings') .inspectBody() .expect('status', 200) .then(async (res) => { const fullBody = JSON.parse(res.body); const idNum = fullBody.resultList[0].id; console.log(idNum); frisby .del('https://desdsdl.com/api/settings/user-settings/' + idNum, { body: JSON.stringify({ id: idNum }) }) .then(async () => { frisby.timeout(timeout) .get('https://desdsdl.com/api/settings/user-settings') .inspectBody() .expectNot('bodyContains', 87172) }, timeout) }, timeout) .done(done) });
frisby log shows the following
`Cannot log after tests are done. Did you forget to wait for something async in your test?
Attempted to log "
FAILURE Status: 200
JSON: {
"resultList": [
{
"id": 87170,
UnhandledPromiseRejectionWarning: Error: expectNot('bodyContains', 87172) passed and was supposed to fail
UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.`
Very hard to read...
fit('Verify deleting last created table, API will return status code 200', async (done)=> {
return frisby.timeout(timeout)
.get('https://dev.sdsdsd.com/api/settings/user-settings')
.inspectBody()
.expect('status', 200)
.then(async (res) => {
const fullBody = JSON.parse(res.body);
const idNum = fullBody.resultList[0].id;
console.log(idNum);
frisby.del('https://desdsdl.com/api/settings/user-settings/' + idNum, { body: JSON.stringify({ id: idNum }) })
.then(async () => {
frisby.timeout(timeout)
.get('https://desdsdl.com/api/settings/user-settings')
.inspectBody()
.expectNot('bodyContains', 87172)
}, timeout)
}, timeout)
.done(done)
});
Try this.
#429 (comment)
@H1Gdev
Thanks for fast reply, issue has been resolved by removing done callback and add retrun to frisby in all area that i was calling only frisby
do not use done
.
fit('Verify deleting last created table, API will return status code 200', async ()=> {
return frisby.timeout(timeout)
.get('https://dev.sdsdsd.com/api/settings/user-settings')
.inspectBody()
.expect('status', 200)
.then((res) => {
const fullBody = JSON.parse(res.body);
const idNum = fullBody.resultList[0].id;
console.log(idNum);
return frisby.del('https://desdsdl.com/api/settings/user-settings/' + idNum, { body: JSON.stringify({ id: idNum }) })
.then(() => {
return frisby.timeout(timeout)
.get('https://desdsdl.com/api/settings/user-settings')
.inspectBody()
.expectNot('bodyContains', 87172)
}, timeout)
}, timeout);
});
Out of curiosity, where did you learn to use the done
function?
The docs and all the examples I am aware of use return
: https://www.frisbyjs.com/
I feel like the explicit return
is a footgun, why not suggest it('...', async () => { await frisby... })
? There are lints for not await
ing promises that would catch this as well.