How to configure Angular2 Quickstart to run phantomjs?

偶尔善良 提交于 2020-01-04 06:08:29

问题


I am trying to figure out how to run the tests of Angular2 Quickstart with phantomjs.

I thought these steps were enough to configure Karma:

1. Clone the repository

$ git clone https://github.com/angular/quickstart.git
$ cd quickstart

2. Install phantomjs and phantomjs launcher

$ npm install --save-dev phantomjs
$ npm install --save-dev karma-phantomjs-launcher

3. Change karma.conf.js

// First change
require('karma-chrome-launcher') => require('karma-phantomjs-launcher')

// Second change
browsers: ['Chrome'] => browsers: ['PhantomJS']

4. Install Quickstart App

$ npm install

5. Run tests

$ npm run test-once

The following error is reported:

PhantomJS 2.1.1 (Linux 0.0.0) ERROR TypeError: undefined is not a function (evaluating 'System.config') at karma-test-shim.js:30

What am I missing or doing wrong?

Thanks.


回答1:


There's an error before that one: a 404 trying to find the system-polyfills.js.

404: /base/node_modules/systemjs/dist/system-polyfills.js

If you add that to the karma config, the error will go away.

files: [
  // System.js for module loading
  'node_modules/systemjs/dist/system.src.js',
  'node_modules/systemjs/dist/system-polyfills.js',

Not quite sure what the difference is (why it's not needed for Chrome). I'm guessing this issue is yours. You should ask them.



来源:https://stackoverflow.com/questions/40470806/how-to-configure-angular2-quickstart-to-run-phantomjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!