I have this Angular Node app and I am in the process of trying to get Jasmine and Karma set up.
However, when I try to run a simple test, I am receiving this error
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
);
}
I am scratching my head why!!! please help
Fixed it by adding Babel as the pre processor!!
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"]
}
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.