-
This is the Mocha test after integrating fast-check
here in the console.log Any suggestions would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Answered by
dubzzz
Oct 4, 2023
Replies: 1 comment 2 replies
-
Your test seem to be for an asynchronous piece of code, you should go for You might probably adapt it that way (I just replaced property by asyncProperty): it.only('should return an error when the user does not exist fuzzing', () => {
return new Promise((resolve, reject) => {
fc.assert(
fc.asyncProperty(
fc.nat().map((randomString) => `lkajdfijain${randomString}`),
(name) => {
return new Promise((innerResolve, innerReject) => {
request
.get(api('users.info'))
.set(credentials)
.query({
username: name,
})
.expect('Content-Type', 'application/json')
.expect(400)
.expect((res) => {
console.log('res.body: ', res.body);
expect(res.body).to.have.property('success', false);
expect(res.body).to.have.property('error');
})
.end((err) => {
if (err) {
innerReject(err);
} else {
innerResolve();
}
});
});
}
),
{ verbose: true }
)
.then(resolve)
.catch(reject); // Resolve or reject the outer promise based on the result of fc.assert
});
}); Note: prefer async/await, it might drop some unneeded code. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same with async/await would be: