因果报应并没有执行测试用例
karma is not executing test case
我是因果报应的新手。我无法执行测试用例。我有以下设置。
karma.config.js
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'angular.js','angular-mocks.js' ,'tests/firstTest.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
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 these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
firstTest.js
describe("First Test", function () {
// Arrange (set up a scenario)
var counter;
beforeEach(function () {
counter = 0;
});
it("increments value", function () {
// Act (attempt the operation)
counter++;
// Assert (verify the result)
expect(counter).toEqual(1);
})
it("decrements value", function () {
// Act (attempt the operation)
counter--;
// Assert (verify the result)
expect(counter).toEqual(0);
})
});
当使用"karma start karma.config.js"命令时,我得到了以下输出。
INFO[karma]:karma v0.12.31 server started at http://localhost:9876/
INFO[launcher]:Starting broswer Chrome
INFO[Chrome 41.0.2272 (windows 7)]: connected on socket ...... with id 98...
但之后什么也没发生,在chrome浏览器中它只显示
karma v0.12.31 Connected
chrome 41 (windows 7 ) executing.
我可以在浏览器中看到我的第一个Test.js加载。我真的不知道我的代码出了什么问题。我指的是"ProAngularJS"这本书。请让我知道我做错了什么。
编辑
我在浏览器控制台中也遇到了一些错误。
Uncaught SyntaxError: Unexpected identifier context.html 28
Uncaught TypeError: Cannot read property 'config' of undefined adapter.js 322
Uncaught TypeError: Cannot read property 'loaded' of undefined context.html
"Karma start"似乎只是启动服务器,而不是运行测试。试着在一个控制台中运行"因果报应启动",在另一个控制台运行"因果报应运行"来实际执行测试。您应该在两个控制台窗口中看到与测试执行相关的输出。
或者,您可以编辑karma.conf.js文件以包含"singleRun":true。然后,当您使用karma start时,它将在一个操作中启动浏览器、运行测试和关闭浏览器。
相关文章:
- angularjs、因果报应和requirejs测试用例错误
- 我们能在&在块到mocha的特定测试用例(it)之后
- 在Karma Jasmine单元测试用例中检查日期格式
- 正在量角器测试用例中从电子邮件中获取值
- 如何将 XML 文件包含在摩卡测试用例中
- 如何将行数计数分配给另一个值,该值稍后可在Protractor中的测试用例中使用
- 如何在启动Mocha测试用例之前添加延迟
- 如何在nightwach中检索当前测试用例名称
- 如何在多个文件中设置摩卡测试用例的执行顺序
- 如何在断言失败时继续测试用例 在 CasperJS 中
- 为什么在我的量角器测试用例中没有定义网络驱动程序
- 猫鼬模型单元测试 - 如果任何测试用例失败,连接将不会关闭
- 如何在量角器 e2e 测试用例失败时发送电子邮件
- 测试用例在 Chrome 中失败
- 如何在摩卡的测试用例中调用另一个测试用例
- 如何处理单元测试用例的q和promise
- ECMAScript 5日期.ISO 8601测试用例的分析结果
- 如何在运行JEST测试用例时将全局变量设置为true
- 如何在jasmine测试用例中模拟$(element).show和ko.mapping.fromJS
- AngularJS-在jasmine测试用例中嘲笑ngTableParams