Assert arrays using Chai (or Should) in Javascript ES6 (using Babel)

£可爱£侵袭症+ 提交于 2019-12-02 00:16:08
Mark Rousskov

The second version (with Babel) does not work because your test forgets to call chai.should(). In my testing, once that method call is added, everything works as expected (the test passes).

It also seems that Bergi was correct in this comment.

If this does not work for you, it seems that in order to help you, we would need more information. It might help to provide the source code of the babelhook --compilers option you are using. (The standard way of referencing Babel from Mocha's compiler option is mocha --compilers js:babel/register.)

Here is my test code:

import chai from 'chai';
chai.should();
import chaiThings from "chai-things";
chai.use(chaiThings);

describe('Array', function() {
   it('Test array', function(cb){
       [{ a: 'cat' }, { a: 'dog' }].should.include.something.that.deep.equals({ a: 'cat' })
        cb();
   });
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!