我一直在为使用angularjs作为前端的客户开发网站。测试是使用量角器编写的。
当我在eclipse中使用Tomcat 8运行站点时,该站点按预期工作,但是当使用npm http-server运行测试时,我的服务在两个指令之间共享数据是不可操作的。 service.variable
始终保持undefined
。
我已经设置了一个Plunker来尽可能多地代表结构
http://plnkr.co/edit/b49YHoFUlwjFUvsn2Y0C?p=preview
的package.json
{
"version": "1.0.5",
"private": true,
"name": "troubleshooting-webapp",
"description": "Troubleshooting REST Service",
"devDependencies": {
"bower": "^1.4.1",
"http-server": "^0.8.5",
"protractor": "^3.0.0",
"protractor-http-mock": "^0.2.1",
"shelljs": "^0.2.6",
"tmp": "0.0.23"
},
"scripts": {
"setup": "npm install",
"start": "cd src/main && http-server -a 0.0.0.0 -p 8000",
"stop": "pkill --signal SIGINT node",
"update-webdriver": "webdriver-manager update",
"preprotractor": "npm run update-webdriver",
"protractor": "protractor src/main/webapp/js/tests/protractor-conf.js",
"preprotractor_debug": "npm run update-webdriver",
"protractor_debug": "protractor debug src/main/webapp/js/tests/protractor-conf.js"
}
}
量角器-conf.js
exports.config = {
allScriptsTimeout: 18000,
specs: [
'e2e/*.js'
],
mocks: {
dir: 'mocks'
},
onPrepare: function(){
require('protractor-http-mock').config = {
rootDirectory: __dirname, // default value: process.cwd()
protractorConfig: 'protractor-conf.js' // default value: 'protractor.conf'
};
},
capabilities: {
'browserName': 'firefox'
},
baseUrl: 'http://localhost:8000/',
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 90000
}
};
为什么filterSelection服务仍未定义的任何想法都应该很好。
经过一些更多的研究,看起来嘲笑似乎也没有加载。