Angular 带量角器ci的角度2端到端测试
我已经用这个软件做了一个项目。我想为它写一些e2e测试。成功地使它们在本地运行,但是在Travis-C中进行e2e测试时,存在一个问题,即找不到测试使用的元素 例如,我有一个侧边栏菜单组件:Angular 带量角器ci的角度2端到端测试,angular,protractor,travis-ci,Angular,Protractor,Travis Ci,我已经用这个软件做了一个项目。我想为它写一些e2e测试。成功地使它们在本地运行,但是在Travis-C中进行e2e测试时,存在一个问题,即找不到测试使用的元素 例如,我有一个侧边栏菜单组件: import {Component} from '@angular/core'; import { ROUTER_DIRECTIVES } from '@angular/router'; @Component({ selector: 'sidebar-menu', directives:
import {Component} from '@angular/core';
import { ROUTER_DIRECTIVES } from '@angular/router';
@Component({
selector: 'sidebar-menu',
directives: [ ROUTER_DIRECTIVES ],
templateUrl: 'app/shared/sidebar-menu/sidebar-menu.html'
})
export class SidebarMenuComponent {}
使用侧栏菜单html:
<div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
<div class="menu_section">
<h3>Algemeen</h3>
<ul class="nav side-menu">
<li><a [routerLink]="['/']"><i class="fa fa-home"></i> Home <span class="fa fa-chevron-down"></span></a></li>
</ul>
</div>
</div>
当我使用npm run e2e.ci
在本地运行它时,它工作并且测试通过。然而,travis ci的测试没有通过,它只是说“预期”等于“ALGEMEEN”。不知道我做错了什么
我使用Angular 2 RC1,travis使用NodeJS 5/6
Travis ci输出:
1) Sidebar Side menu should have the right title
Message:
Expected '' to equal 'ALGEMEEN'.
Stack:
Error: Failed expectation
at Object.<anonymous> (app/shared/sidebar-menu/sidebar-menu.component.e2e-spec.ts:11:60)
at /home/travis/build/node_modules/jasminewd2/index.js:96:23
at new Promise (/home/travis/build/node_modules/selenium-webdriver/lib/promise.js:1043:7)
at controlFlowExecute (/home/travis/build/node_modules/jasminewd2/index.js:82:18)
at TaskQueue.execute_ (/home/travis/build/node_modules/selenium-webdriver/lib/promise.js:2790:14)
at TaskQueue.executeNext_ (/home/travis/build/node_modules/selenium-webdriver/lib/promise.js:2773:21)
at /home/travis/build/node_modules/selenium-webdriver/lib/promise.js:2697:25
at /home/travis/build/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
progrator.conf.js:
const config = {
baseUrl: 'http://localhost:5555/',
restartBrowserBetweenTests: false,
specs: [
'./dist/dev/**/*.e2e-spec.js'
],
exclude: [],
// 'jasmine' by default will use the latest jasmine framework
framework: 'jasmine2',
// allScriptsTimeout: 110000,
jasmineNodeOpts: {
// showTiming: true,
showColors: true,
isVerbose: false,
includeStackTrace: false,
// defaultTimeoutInterval: 400000
},
directConnect: true,
capabilities: {
browserName: 'chrome'
},
onPrepare: function() {
const SpecReporter = require('jasmine-spec-reporter');
// add jasmine spec reporter
jasmine.getEnv().addReporter(new SpecReporter({ displayStacktrace: true }));
browser.ignoreSynchronization = false;
},
/**
* Angular 2 configuration
*
* useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching
* `rootEl`
*/
useAllAngular2AppRoots: true
};
if (process.env.TRAVIS) {
config.capabilities = {
browserName: 'firefox'
};
}
exports.config = config;
定位器应该是
#侧边栏菜单h3
-输入错误?哦,我不知道这是一个要求。然而,这并不能解决特拉维斯的问题。仍然在本地工作。
language: node_js
node_js:
- 5
- 6
sudo: false
before_install:
- export CHROME_BIN=chromium-browser # Karma CI
- export DISPLAY=:99.0
before_script:
- sh -e /etc/init.d/xvfb start
- nohup bash -c webdriver-manager start 2>&1 & # Protractor CI
- sleep 1 # give server time to start
after_failure:
- cat /home/travis/build/mgechev/angular2-seed/npm-debug.log
cache:
directories: node_modules
script:
- npm run tests.all
const config = {
baseUrl: 'http://localhost:5555/',
restartBrowserBetweenTests: false,
specs: [
'./dist/dev/**/*.e2e-spec.js'
],
exclude: [],
// 'jasmine' by default will use the latest jasmine framework
framework: 'jasmine2',
// allScriptsTimeout: 110000,
jasmineNodeOpts: {
// showTiming: true,
showColors: true,
isVerbose: false,
includeStackTrace: false,
// defaultTimeoutInterval: 400000
},
directConnect: true,
capabilities: {
browserName: 'chrome'
},
onPrepare: function() {
const SpecReporter = require('jasmine-spec-reporter');
// add jasmine spec reporter
jasmine.getEnv().addReporter(new SpecReporter({ displayStacktrace: true }));
browser.ignoreSynchronization = false;
},
/**
* Angular 2 configuration
*
* useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching
* `rootEl`
*/
useAllAngular2AppRoots: true
};
if (process.env.TRAVIS) {
config.capabilities = {
browserName: 'firefox'
};
}
exports.config = config;