Run javascript es6 code in Jasmine

前端 未结 3 871
醉话见心
醉话见心 2021-01-13 08:05

I am exploring JavaScript es6 code in angularjs app and used grunt babel to compile the es6 to es5.

My unit test (jasmine) doesn\'t run with es6 code using phantomjs

3条回答
  •  被撕碎了的回忆
    2021-01-13 08:27

    I spent quite some time to make babel & jasmine to cooperate, so i should post my solution here:

    install babel-cli package, do standard babel config (for me it was .babelrc file)

    i created custom runner file: bin/jasmine

    #!/usr/bin/env bash
    ./node_modules/.bin/babel-node ./node_modules/.bin/jasmine $@ --config=spec/support/jasmine.json
    

    that way even passing arguments works! bin/jasmine -h while path to config conveniently always defined

提交回复
热议问题