繁体   English   中英

在流星测试中不能使用导入

[英]Can't use import in meteor testing

我不明白这个错误。 为什么不能使用import

import { chai } from 'meteor/practicalmeteor:chai';
^^^^^^
SyntaxError: Unexpected reserved word

package.js

Package.onTest(function(api) {
    api.use('practicalmeteor:mocha');

    api.addFiles('tests/test.js');
});

test.js

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

describe('Array', function() {
    describe('#indexOf()', function () {
        it('should return -1 when the value is not present', function () {
            chai.assert.equal(-1, [1,2,3].indexOf(5));
            chai.assert.equal(-1, [1,2,3].indexOf(0));
        });
    });
});

通常,这表明(如此处所示)您没有在onTest中包含ecmascript包。

Package.onTest(function(api) {
    api.use('ecmascript');
    api.use('practicalmeteor:mocha');

    api.addFiles('tests/test.js');
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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