简体   繁体   English

如何配置Angular2快速入门以运行phantomjs?

[英]How to configure Angular2 Quickstart to run phantomjs?

I am trying to figure out how to run the tests of Angular2 Quickstart with phantomjs. 我试图弄清楚如何使用phantomjs运行Angular2 Quickstart的测试。

I thought these steps were enough to configure Karma: 我认为这些步骤足以配置Karma:

1. Clone the repository 1.克隆存储库

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

2. Install phantomjs and phantomjs launcher 2.安装phantomjs和phantomjs启动器

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

3. Change karma.conf.js 3.更改karma.conf.js

// First change //第一次更改
require('karma-chrome-launcher') => require('karma-phantomjs-launcher') require('karma-chrome-launcher')=> require('karma-phantomjs-launcher')

// Second change //第二个变化
browsers: ['Chrome'] => browsers: ['PhantomJS'] 浏览器:['Chrome'] =>浏览器:['PhantomJS']

4. Install Quickstart App 4.安装快速入门应用

$ npm install

5. Run tests 5.运行测试

$ 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 PhantomJS 2.1.1(Linux 0.0.0)错误TypeError:在karma-test-shim.js:30处undefined不是函数(评估'System.config')

What am I missing or doing wrong? 我想念什么或做错什么?

Thanks. 谢谢。

There's an error before that one: a 404 trying to find the system-polyfills.js . 在此之前有一个错误:404试图找到system-polyfills.js

404: /base/node_modules/systemjs/dist/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). 不太清楚区别是什么(为什么Chrome不需要它)。 I'm guessing this issue is yours. 我猜这个问题是你的。 You should ask them. 你应该问他们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM