我的ng test的输出如下:
> ng test
24 12 2019 14:20:07.854:WARN [karma]: No captured browser, open http://localhost:9876/
24 12 2019 14:20:07.860:INFO [karma-server]: Karma v4.4.1 server started at http://0.0.0.0:9876/
24 12 2019 14:20:07.860:INFO [launcher]: Launching browsers ChromeNoSandbox with concu
我目前忙于茉莉花单元测试角。我已经把这个单元测试放到了test.js中
describe('The countInput filter', function(){
var $filter;
beforeEach(function(){
module('countInputFilter');
inject(function(_$filter_){
$filter = _$filter_;
});
});
it('Should not give an
我们所有的业力单元测试似乎在我们的自动化构建中都成功了,但是PhantomJS运行程序将一个非零的结果返回到构建框架(TeamCity)。我在日志中唯一能找到的错误是:
[17:53:31][JavaScript Unit Tests] PhantomJS 2.1.1 (Windows 8.0.0) ERROR
[17:53:31][JavaScript Unit Tests] An error was thrown in afterAll
[17:53:31][JavaScript Unit Tests] SyntaxError: Unexpected token ',
我希望为我的angular应用程序设置一个基本的单元测试,特别是离子应用程序。我使用的是karma/jasmine,使用的是ionic团队预先配置的解决方案。所包含的样例单元测试通过了,因此我继续为我自己的提供者编写新的单元测试。
这就是我遇到麻烦的地方,因为没有真正的样本可供参考。因此,我只创建了一个TestBed,并像处理应用程序一样将所需的最少组件放入其中。但是,每次我运行单元测试时,都会出现一个相当模糊且无法描述的错误:Error: Illegal state: Could not load the summary for directive TestServiceProvider.
错误:实际上在窗口上找不到对象。
Error: Plotly object not found on window.
at new PlotlyViaWindowModule (http://localhost:9876/_karma_webpack_/webpack:/node_modules/angular-plotly.js/fesm2015/angular-plotly.js.js:634:1)
at Object.PlotlyViaWindowModule_Factory [as factory] (http://localhost:9876/_karma_webpack_/webp
在运行角单元测试时,使用chrome浏览器,最终导致错误为
TypeError: userAgent.toLowerCase is not a function
at _isAndroid (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/forms/fesm2015/forms.mjs:176:43)
at new DefaultValueAccessor (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angu
在我的angular js测试中,我得到了这个错误:
Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it.
尝试为我的服务编写单元测试时,它是这样开始的:
var $httpBackend, httpBasedService;
beforeEach
在单元测试中,我在访问服务和过滤器时遇到了困难(我还没有尝试指令)。我以前写过单元测试,但是当我转向构建的配置时,我在访问我们的新服务编写单元测试时遇到了困难。我不断地得到TypeError: null is not an object (evaluating 'currentSpec.$modules') in...。我做了一些阅读,看起来这可能与我正在使用的节点包有关。我想知道更大的社区是否能够确保这些配置看起来正确。我把下面的文件缩略下来了。
对于当前的配置,这是错误的。
package.json
"devDependencies": {
"a
当使用karma运行Jasmine单元测试时,karma会将以下内容输出到控制台:
INFO [PhantomJS 1.9.7 (Linux)]: Connected on socket Tbp5etNZBA7QCK_cBaJL with id 89324857
PhantomJS 1.9.7 (Linux) ERROR
TypeError: 'undefined' is not a function (evaluating 'jasmineEnv.executeFiltered()')
at /home/thalley887/Documents/Project
我正在用Karma和jasmine做基于angular 1.3.15的单元测试。在我的单元测试中,我注入了$rootScope并运行了$rootScope.$digest(),然后我得到了这样的错误提示:browser.cookies is not a function。这是一个角度错误,还是我错过了什么?
我尝试使用karma运行单元测试,但得到了错误You need to include some adapter that implements __karma__.start method!。我尝试使用grunt和karma start命令运行。我做了谷歌搜索,所有的解决方案都不起作用。不知道我做错了什么。我在karma.conf.js文件中的plugins下包含了与karma-jasmine一起提供的右边的适配器,它有__karma__.start方法。这是我的配置文件:
module.exports = function(config){
config.set({
// root p
我正在进行的一个项目正在使用Pusher,以及用于单元测试的Karma。单元测试当前失败,原因是出现以下错误:
ReferenceError: Can't find variable: Pusher
at runBlock (/vagrant/front/src/app/index.run.js:9)
at invoke (/vagrant/front/bower_components/angular/angular.js:4771)
at /vagrant/front/bower_components/angular/angular.js:4578
a
我在app/scripts下定义了一个相当简约的app (一个控制器,三个指令)。
当使用karma start运行karma时,我导航到localhost:9100,单元测试就会运行。但是,当我使用karma start karma-2e2.conf.js运行时,运行错误输出为:
[31mChrome 27.0 (Mac) I haz all the things I haz grid FAILED[39m
TypeError: Cannot read property 'name' of undefined
Chrome 27.0 (Mac): Execut
我看到很多人发布关于NullInjectorError: No provider for HttpClient!的问题,但我在我的Karma单元测试中得到了一个更具描述性的错误。我一直在与Javascript/Typescript、HTML和CSS/SCSS并行学习Angular,所以我的基础有点不稳定。我如何修复这个错误?对于那些说是因为OP忘记导入测试模块的人,我已经导入了测试模块。下面是我的测试文件的样子。当我注释掉html中的所有内容时,仍然会收到这个错误。此外,我还尝试将ApiService存根。 错误: NullInjectorError: R3InjectorError(Dyn
我正尝试在teamcity (version 7.1).上运行我的karma (version v0.10.2)单元测试
当我运行karma start --reporters teamcity --single-run时,我得到以下错误:
Can not load "teamcity", it is not registered! Perhaps you are missing some plugin?
我已经安装了karma-teamcity-reporter模块,但这并没有帮助。
我的本地node_modules文件夹中安装了以下软件:
karma
karma-chro
这是我的karma.conf.js
`use strict`;
var path = require('path');
var conf = require('./gulp/conf');
var _ = require('lodash');
var wiredep = require('wiredep');
var pathSrcHtml = [
path.join(conf.paths.src, '/**/*.html')
];
function listFiles() {
var wirede
是否可以使用karma runner检测单元测试中的控制台错误,并将单元测试用例标记为失败。在我目前的项目中,我有数百个测试,而项目并不处于干净的状态。当我使用ng test运行单元测试时,我得到了成百上千条控制台消息,比如 ERROR: ''mat-icon' is not a known element:
1. If 'mat-icon' is an Angular component, then verify that it is part of this module.
2. If 'mat-icon' is a Web Com
我的应用程序有很多模块,有许多组件和服务以及其他Angular2功能。
现在,我正在尝试使用TestBed方法创建一个带有茉莉花+业力的单元测试。
我在揭示概念的证据时遇到了一个错误。我为我的一个组件创建了一个测试,如下所示:
let myCompServiceStub = {} as MyComponentService;
let routerStub = {} as Router;
let globalServiceStub = {} as MyGlobalService;
describe('MyComponent', () => {
let compo