Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert.exists is not a function #1207

Closed
lubodrinka opened this issue Nov 12, 2018 · 9 comments
Closed

assert.exists is not a function #1207

lubodrinka opened this issue Nov 12, 2018 · 9 comments

Comments

@lubodrinka
Copy link

lubodrinka commented Nov 12, 2018

I tried it on a functional model and change the function exists not know
dependencies": {
"express": "^4.14.0",
"cors": "^2.8.1",
"body-parser": "^1.15.2",
"chai": "^3.5.0",
"mongodb": "^3.1.3",
"chai-http": "^3.0.0",
"mocha": "^3.2.0",
"zombie": "^5.0.5",
"helmet": "^3.1.0",
"mongoose": "^5.2.8",
"x-xss-protection": "^1.1.0"
},

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){
     if(err)   console.log( err);
      assert.equal(res.status, 200);
  //   console.log(  res.body.issue_text);
    // console.log( "re"+JSON.stringify( res));
      assert.isDefined(res.body.issue_title,title);
     assert.exists(res.body.issue_text,'text');
        assert.equal(res.body.created_by,'Functional Test - Every field filled in');
       assert.equal(res.body.assigned_to,'Chai and Mocha');
       assert.equal(res.body.status_text,'In QA');
       idtest=res.body._id
      done();
    });
@keithamus
Copy link
Member

Hey @lubodrinka thanks for this issue!

Check to make sure you're doing const {assert} = require('chai'). node.js comes with an assert package by default, but it does not include all of the chai funtionality. You need to manually include chai's assert like above.

Thank you for your time in reporting this. I'm going to close this, because it is not a bug within chai. If you do find any bugs please don't hesitate to report them in future 😄

@lubodrinka
Copy link
Author

this is worse than previous
var chaiHttp = require('chai-http');
var chai = require('chai');
const {assert} = require('chai')
var server = require('../server');
var idtest;
var title='Title1'+ new Date()
chai.use(chaiHttp);

@meeber
Copy link
Contributor

meeber commented Nov 12, 2018

Hi @lubodrinka. assert.exists wasn't released until Chai v4.0.

@lubodrinka
Copy link
Author

lubodrinka commented Nov 12, 2018

So, it,s bug: https://www.chaijs.com/api/assert/ , I even dont know whati is actual version.
Is there problem to each function write (from version 4.0)?

@keithamus
Copy link
Member

Please see chaijs/chaijs.github.io#178 which is an issue that plans to reflect version numbers for this stuff.

@lubodrinka
Copy link
Author

Hey this os nonsense, nobody look in there, nobody. rewrite the manual.

@meeber
Copy link
Contributor

meeber commented Nov 12, 2018

@lubodrinka Chai is an open source project maintained by unpaid volunteers, that relies on the contributions of other unpaid volunteers. Currently the documentation only reflects the latest version of Chai (v4.2.0), but as @keithamus mentioned, a volunteer in chaijs/chaijs.github.io#178 has offered to improve the website so that the docs for older versions of Chai are available as well.

Do you have a requirement to use Chai v3.5.0 even though it's 2+ years old and unmaintained? If not, then I suggest upgrading to Chai v4.2.0, in which case you'll be able to use chai.asserts and the docs will match the API.

@lubodrinka
Copy link
Author

Oh god you are lazy man.
Let assume use 4.0. and you don't have somewhere that must be with new declarations in brackets.
So if somebody try that oh that not working so rather use 3.5 version.
there is tons of prefabricated solutions or done with 3.5 and someone want add another function ..
I don't even believe I must tell you.

@chaijs chaijs locked as too heated and limited conversation to collaborators Nov 12, 2018
@keithamus
Copy link
Member

@lubodrinka participation in the chai issue tracker is dependant on our Code of Conduct. Please read it and adhere to it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants