如何配置Angular2快速入门以运行phantomjs? [英] How to configure Angular2 Quickstart to run phantomjs?
问题描述
我正在尝试找出如何使用phantomjs运行 Angular2快速入门的测试.
I am trying to figure out how to run the tests of Angular2 Quickstart with phantomjs.
我认为这些步骤足以配置Karma:
I thought these steps were enough to configure Karma:
1.克隆存储库
$ git clone https://github.com/angular/quickstart.git
$ cd quickstart
2.安装phantomjs和phantomjs启动器
$ npm install --save-dev phantomjs
$ npm install --save-dev karma-phantomjs-launcher
3.更改karma.conf.js
//第一次更改
require('karma-chrome-launcher')=> require('karma-phantomjs-launcher')
// First change
require('karma-chrome-launcher') => require('karma-phantomjs-launcher')
//第二次更改
浏览器:['Chrome'] =>浏览器:['PhantomJS']
// Second change
browsers: ['Chrome'] => browsers: ['PhantomJS']
4.安装快速入门应用
$ npm install
5.运行测试
$ npm run test-once
报告以下错误:
PhantomJS 2.1.1(Linux 0.0.0)错误 TypeError:未定义不是函数(正在评估"System.config") 在karma-test-shim.js:30
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?
谢谢.
推荐答案
在此之前有一个错误:404试图找到system-polyfills.js
.
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
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',
不太确定有什么区别(为什么Chrome不需要此区别).我猜此问题是您的.你应该问他们.
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.
这篇关于如何配置Angular2快速入门以运行phantomjs?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!