我有这个Angular Node应用程序,我正在尝试设置Jasmine和Karma。
但是,当我尝试运行简单测试时,我收到此错误
Uncaught SyntaxError: Unexpected token import
at specs / boxService.spec.js:2
boxService.spec.js
import { BoxService } from './services/boxService.js';
describe("BoxService", function() {
var service;
beforeEach(function(){
service = new BoxService
});
describe('getAllItemsInRootFolder', function() {
it('returns an object representing all the files in Box', function() {
let callBack = function(err, data) {
if(err) throw err;
expect(data).toNotBe(null)
}
service.getAllItemsInRootFolder(callBack)
});
});
boxService.js
export class BoxService{
var developerToken = 'IdSqAIHSUCkD7J67hVsVR1FjWtkrODre'
getAllItemsInRootFolder(callBack){
client.folders.getItems( '0', {
fields: 'name,modified_at,size,url,permissions,sync_state',
offset: 0,
limit: 25 }, callBack
);
}
我为什么要挠头!请帮忙
答案 0 :(得分:0)
通过添加Babel作为预处理器来修复它!
的package.json
"dependencies": {
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.23.0",
"babel-register": "^6.23.0",
"box-node-sdk": "^1.3.0",
"ejs": "2.4.1",
"express": "4.13.3"
},
.babelrc
{
"presets": ["es2015"]
}