Hi there. can anyone give me pointers on how to test my project. There are empty spaces in the 2_functional-tests.js file that needs to filled in. I have no clear idea as to where to start. A few tips would be helpful. Thank you
there is a first filled test. copy and change the conditions.
equal or find more at
https://www.chaijs.com/api/assert/
Thanks for replying. I have tried this:
test('Every field filled in', function(done) {
chai.request(server)
.post('/api/issues/test')
.send({
issue_title: 'Title',
issue_text: 'text',
created_by: 'Functional Test - Every field filled in',
assigned_to: 'Chai and Mocha',
status_text: 'In QA'
})
.end(function(err, res){
assert.equal(res.status, 200);
assert.exists(res.body.issue_title);
assert.exists(res.body.issue_text)
assert.exists(res.body.created_by);
assert.exists(res.body.assigned_to);
assert.exists(res.body.status_text);
assert.exists(res.body.created_on);
assert.exists(res.body.updated_on);
assert.exists(res.body.open);
assert.exists(res.body._id)
done();
});
});
Is it something like this? I’m failing the test though.
Yes. watch out the unnecessary parts as update_on the test is about filled fields on html site
Thanks. Sorry if I’m asking too much, I tried removing the updated_on, created_on, open and _id
. It is still failing.
I send you the demand to join on glitch because I cant see the debbuger
Sure, I have accepted. Thank you
It look it is problem with the chai itself assert.exists is not a function.
I try defined an it worked
var chai = require('chai');
Like this?
assert.isDefined(res.body.issue_title);
Will try that. Thanks
That weird according test on site the exists working on edge, but even the example
assert(‘foo’ !== ‘bar’, ‘foo is not bar’); not working.
I had idea
assert(Boolean(‘bar’), ‘foo is not bar’);
but something must wrong with chai.
Hmm… noted… Thanks for your help
I have get on assert github and after hour they say it,s from 4.0 version, so change the depencies “chai”: “^4.0.0”,
and new declarations
const {assert} = require(‘chai’)
Yes, it can now recognise exist. If you don’t mind, can you explain how to do the first test? I’m testing it in https://pricey-hugger.glitch.me/ but the last 4 tests are failing.