我遇到了一个量角器问题,即Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL
来自我的protractor.conf.js:
onPrepare: function () {
//Mail config
require('./test/e2e/config/mailin.js');
}
这是mailin.js配置:
var mailin = require('mailin');
mailin.start({
port: 2525,
disableDNSValidation: true,
disableWebhook: true // Disable the webhook posting.
});
mailin.on('startMessage', function (connection) {
console.log(connection);
});
/* Event emitted after a message was received and parsed. */
mailin.on('message', function (connection, data, content) {
console.log(data);
/* Do something useful with the parsed message here.
* Use parsed message `data` directly or use raw message `content`. */
});
var getLastEmail = function () {
var deferred = protractor.promise.defer();
console.log("Waiting for an email...");
mailin.on('message', function (connection, data, content) {
deferred.fulfill(data);
});
return deferred.promise;
};
var extractToken = function (email) {
var deferred = protractor.promise.defer();
var pattern = /\/#\/useraccount\/activate\/(\S+)">/g;
var result = pattern.exec(email.html);
var token = result[1];
deferred.fulfill(token);
return deferred.promise;
};
global.getLastEmail = getLastEmail;
global.extractToken = extractToken;
最后我的测试用例:
describe('Signup page', function () {
var signupPage = new SignupPage();
beforeEach(function () {
signupPage.get();
});
it('should allow user to signup', function () {
signupPage.chooseParentsType();
signupPage.typeFirstName('Julien');
signupPage.typeEmail('me@bignibou.localhost');
signupPage.typePassword('------');
signupPage.typeAddress('5 rue Sainte Anast');
signupPage.scroll();
signupPage.firstAddress();
signupPage.signup();
browser.controlFlow().execute(getLastEmail).then(extractToken).then(showToken);
});
function showToken(token){
console.log('And the token is... ', token);
};
});
我从量角器得到以下错误:
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
warn: Either spamassassin or spamc are not available. Spam score computation is disabled.
Started
info: Mailin Smtp server listening on port 2525
. Waiting for an email...
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
F
Failures:
1) Signup page should allow user to signup
Message:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Stack:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at [object Object]._onTimeout (/Users/julien/Documents/projects/bignibou/bignibou-site/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1812:23)
2 specs, 1 failure
有人可以帮忙吗?
修改:以下是我的应用使用的版本:
package.json
{
"name": "bignibou-client",
"private": true,
"engines": {
"node": "0.12.x"
},
"devDependencies": {
"assemble-less": "~0.7.0",
"bower": "1.6.2",
"flow": "~0.2.3",
"grunt": "~0.4.5",
"grunt-angular-templates": "^0.5.7",
"grunt-contrib-clean": "~0.6.0",
"grunt-contrib-concat": "~0.5.0",
"grunt-contrib-copy": "~0.7.0",
"grunt-contrib-cssmin": "~0.10.0",
"grunt-contrib-uglify": "~0.6.0",
"grunt-filerev": "~2.1.2",
"grunt-karma": "~0.12.1",
"grunt-mkdir": "~0.1.2",
"grunt-usemin": "~2.6.2",
"karma": "~0.13.15",
"karma-coverage": "^0.5.3",
"karma-htmlfile-reporter": "~0.1.2",
"karma-jasmine": "~0.3.6",
"karma-junit-reporter": "~0.3.7",
"karma-phantomjs-launcher": "~0.2.1",
"mailin": "^3.0.1",
"phantomjs": "~1.9.18",
"protractor": "2.5.1"
},
"scripts": {
"postinstall": "node_modules/.bin/bower install"
}
}