我正在为我的 Web 应用程序编写 e2e 测试,并在一开始就卡住了。我将不胜感激任何帮助开始我的测试体验。
我对 angularjs 完全陌生。所以请多多包涵。
我想编写一个测试来检查我们是否在应用程序的登录页面上。我正在使用茉莉花和业力。
这是我的配置文件 // Karma 配置
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '../',
// frameworks to use
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'source/assets/vendor/angular/angular.js',
'test/lib/angular-mocks.js',
'test/scripts/**/*.js',
'test/unit/**/*.js',
'test/e2e/**/*.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,
// 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 the browser, currently available:
browsers: ['Chrome'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};
我的 mainscenario.js 文件。
describe('appName', function() {
beforeEach(function() {
browser().navigateTo('../../source/views/home/landing.html');
});
it('should automatically redirect to landing page when location hash/fragment is empty', function() {
expect(browser().location().url()).toBe("/landing");
});
好吧,我不能发布错误的屏幕截图,因为它需要 10 名声望。但这里有一个描述。
AngularJS: Scenario Test Runner1 Errors0 Failures0 Passed
describe: appName
165ms should automatically redirect to landing page when location hash/fragment is empty
118ms browser navigate to '../../source/views/home/landing.html'
8ms $location.url()
http://localhost:8000/test/e2e/mainscenario.js:9:16
TypeError: Object [object Object] has no method 'injector'
at Object.<anonymous> (http://localhost:8000/test/lib/angular-scenario.js:27230:30)
...........blah blah
提前致谢。