How to properly require modules from mocha.opts file

后端 未结 3 1584
天命终不由人
天命终不由人 2021-02-03 10:52

I\'m using the expect.js library with my mocha unit tests. Currently, I\'m requiring the library on the first line of each file, like this:

var expect = require         


        
3条回答
  •  不思量自难忘°
    2021-02-03 11:27

    While Louis's answer is spot on, in the end I solved this with a different approach by using karma and the karma-chai plugin:

    Install:

    npm install karma-chai --save-dev
    

    Configure:

    karma.set({
    
        frameworks: ['mocha', 'chai']
        // ... 
    });
    

    Use:

    describe('something', function () {
        it('should pass', function () {
            expect(true).to.be(true); // works
        });
    });
    

提交回复
热议问题