[英]How to run knex migrations from Dockerfile or docker-compose
[英]how to run protractor tests in docker-compose
我在使用使用docker image的量角器框架進行啟動測試時遇到問題。 當我在本地硒服務器中開始測試時,測試成功。 但是當我使用docker image時出現錯誤E /量角器-無法在頁面http:// localhost:4200 /上找到Angular:重試以尋找超出角度的角度 。
我的config.js
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://hub:4444/wd/hub',
specs: ['e2e/myTest.js'],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
args: ['--no-sandbox']
}
},
chromeOnly: true
};
myTest.js
describe('example test', function() {
var homePage = require('./pages/homePage.js');
var homePage = new homePage();
it('my test...', function() {
browser.get('http://localhost:4200/');
....
Package.json文件
{
"name": "client",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "npm install && ng serve -H 0.0.0.0",
"build": "ng build",
"pretest": "webdriver-manager update",
"test": "protractor config.js",
"lint": "ng lint"
},
docker-compose.yml的片段
angular:...
mypayara:...
chrome:
image: selenium/node-chrome:3.9.1-actinium
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
hub:
image: selenium/hub:3.9.1-actinium
ports:
- "4444:4444"
depends_on:
- angular
當我使用命令開始測試時
docker-compose exec angular sh -c“ npm test”
我得到那個錯誤
[18:51:48] E/protractor - Could not find Angular on page http://localhost:4200/ : retries looking for angular exceeded
F[18:51:59] E/protractor - Could not find Angular on page http://localhost:4200/ : retries looking for angular exceeded
F
Failures:
1) Register account test should create a account
Message:
Failed: Angular could not be found on the page http://localhost:4200/.If this is not an Angular application, you may need to turn off waiting for Angular.
Please see
https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load
Stack:
Error: Angular could not be found on the page http://localhost:4200/.If this is not an Angular application, you may need to turn off waiting for Angular.
Please see
https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load
at executeAsyncScript_.then (/usr/src/app/node_modules/protractor/built/browser.js:720:27)
at ManagedPromise.invokeCallback_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:1376:14)
at TaskQueue.execute_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:3067:27)
at asyncRun (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:2927:27)
at /usr/src/app/node_modules/selenium-webdriver/lib/promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: Run it("should create a account") in control flow
at UserContext.<anonymous> (/usr/src/app/node_modules/jasminewd2/index.js:94:19)
From asynchronous test:
Error
at Suite.<anonymous> (/usr/src/app/e2e/registertest.js:7:3)
at Object.<anonymous> (/usr/src/app/e2e/registertest.js:1:63)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
我在連接docker應用程序時遇到問題。 我正在嘗試此測試,結果是成功。
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('https://angularjs.org');
element(by.model('todoList.todoText')).sendKeys('write first protractor test');
element(by.css('[value="add"]')).click();
var todoList = element.all(by.repeater('todo in todoList.todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write first protractor test');
// You wrote your first test, cross it off the list
todoList.get(2).element(by.css('input')).click();
var completedAmount = element.all(by.css('.done-true'));
expect(completedAmount.count()).toEqual(2);
});
});
您知道我可以解決這個問題嗎?
只是要檢查原因是否為Angular,請將此行添加到代碼中的“ it”塊中。
await browser.waitForAngularEnabled(false);
看看發生了什么
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.