Skip to content

Instantly share code, notes, and snippets.

@mauvm
Created November 12, 2015 10:51
Show Gist options
  • Save mauvm/172878a9646095d03fd7 to your computer and use it in GitHub Desktop.
Save mauvm/172878a9646095d03fd7 to your computer and use it in GitHub Desktop.
Jasmine ES6 run script for use with Babel 6
$ npm install --save babel-cli babel-preset-es2015
$ npm install --save-dev jasmine

.babelrc:

{
  "presets": ["es2015"]
}

package.json:


"scripts": {
  "test": "babel-node spec/run.js"
},

spec/run.js:

import Jasmine from 'jasmine'

var jasmine = new Jasmine()
jasmine.loadConfigFile('spec/support/jasmine.json')
jasmine.execute()
@minhnhut1986
Copy link

Awesomeness! Many thanks!

Copy link

ghost commented Aug 10, 2018

Anyone else has this issue?
(function (exports, require, module, __filename, __dirname) { import Jasmine from 'jasmine'; ^^^^^^ SyntaxError: Unexpected token import

@oskee121
Copy link

Same as @cladicovr

@captain-yossarian
Copy link

Same as @cladicovr & @oskee121

@GhadeerHaddad
Copy link

how to run the run.js file? and how to run protractor.conf.js file using babel ?

@MarkMYoung
Copy link

This helped me today. Thank you!

@SerkanSipahi
Copy link

@memememomo
Copy link

Anyone else has this issue?
(function (exports, require, module, __filename, __dirname) { import Jasmine from 'jasmine'; ^^^^^^ SyntaxError: Unexpected token import

It may be a problem with Node.js version. I wrote the following and it was resolved.

// import Jasmine from 'jasmine';
const Jasmine = require('jasmine');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment