2

I'm using the latest node and running jasmine tests on my project only to be met with

jasmine-node spec Exception loading: /usr/src/app/spec/playground/playground.spec.js /usr/src/app/src/engine/playground.Soundcloud.js:1 (function (exports, require, module, __filename, __dirname) { import PLAYGROUND from 'playground.js' SyntaxError: Unexpected token import

my package.json is

{
  "main": "index.js",
  "scripts": {
    "server-server": "nodemon index.js",
    "dev" : "",
    "test": "jasmine-node spec",
    "dev-browsersync": "webpack-browser-sync --webpack false --proxy http://0.0.0.0:8000/",
    "dev-webpack": "webpack-dev-server --progress --colors --host 0.0.0.0 --port 8000  & npm run debug-webpack",
    "start": "webpack --progress --watch",
    "debug-webpack": "node_modules/.bin/weinre --boundHost -all-",
    "postinstall" : "npm run server-server | npm run start"
  }
  "devDependencies": {
    "jasmine":"*",
    "browser-sync":"*",
    "jasmine-await":"*",
    "jasmine-node":"*",
    "request":"*",
    "webpack":"*",
    "nodemon-webpack-plugin":"*",
    "babel-core": "*",
    "babel-loader": "*",
    "babel-preset-env": "*",
    "babel-polyfill": "*",
    "babel-cli":"*",
    "jasmine-core":"*",
    "browser-sync-webpack-plugin":"*",
    "jasmine-expect":"*",
    "imports-loader":"*"
  }

What can be the problem here?

Kendall
  • 5,065
  • 10
  • 45
  • 70

2 Answers2

4

Jasmine does not understand ES6. You'll need to transpile your specs to preset es2015.

RCW
  • 121
  • 2
  • 6
0

While using Jasmin 3.9.0 one day I suddenly received:

/path/to/node_modules/jasmine/lib/loader.js:39
  return import(path);
         ^^^^^^

SyntaxError: Unexpected token import

I was incorrectly using version 8 when I should have been using version 12

DJDaveMark
  • 2,669
  • 23
  • 35