简体   繁体   中英

Mocha test not running Chai assertion using Meteor

For my project, I am trying to set up Mocha to run Chai tests, but am having an issue where the tests are simply not running at all. The browser reports that no tests are passing, failing, or running.

Here is the code for the tests:

import {assert} from 'chai';
import {Meteor} from 'meteor/meteor';

if (Meteor.isclient) {

    describe('Recipe model', function () {
        it('should test that a recipe is created', function () {
            assert.isTrue(true);
        });
    });
}

I run the test using the following command:

    meteor test --driver-package practicalmeteor:mocha

I have installed practicalmeteor:chai as well. A google search suggested putting chai.should() at the beginning of my test, but that did not help. I am open to all suggestions.

Cheers!

One of possible issues is typo at 4th line of your code: replace Meteor.isclient with Meteor.isClient . Your test even didn't executed because Meteor.isclient was always false .

Make sure you do not put your test file inside /tests directory. I know its not intuitive but meteor ignores everything inside /tests.

Turns out I had weird issues with importing assert. I just had to do the following as noted from @Tdm:

import {chai} from 'meteor/practicalmeteor:chai'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM