我有以下 Karma 配置
// Karma configuration
// Generated on Thu Oct 24 2013 16:41:13 GMT+0200 (CEST)
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// frameworks to use
frameworks: ['ng-scenario'],
// list of files / patterns to load in the browser
files: [
'lib/jquery.js',
'test/**/*.js'
],
// list of files to exclude
exclude: [
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],
// web server port
port: 9876,
// cli runner port
runnerPort: 9100,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['PhantomJS', 'Chrome'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 10000,
proxies: {
'/': 'http://localhost:8080/' // Keep this in sync with localhost port in Gruntfile.
},
urlRoot: '/_karma_/',
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};
我有我的测试用例:
'use strict'
describe("A suite", function() {
it("contains spec with an expectation", function() {
browser().navigateTo('/')
$('#username').val('test@example.com')
$('#password').val('*******')
$('.submitLogin').click()
expect(browser().location().url()).toBe('/welcome')
});
});
我可以使用浏览器导航browser().navigateTo('/url');
但我不能强迫它提交我的价值观。有什么想法我怎么能实现它?