-
0 votesanswersviews
spyObj withArgs mock无法按预期工作
在我从上一个问题得到答案后,我试图为my sample添加更多测试 . savePost 模拟效果很好,但我尝试测试 updatePost 路径,它失败了 . PostFormComponent 包含 input 绑定和 output 事件 Launcher . @Component({ selector: 'app-post-form', templateUrl: './post-fo... -
2 votesanswersviews
第三方库测试角2 webpack
我正在使用角度2和第三方库来制作图表(AmCharts) . 我想出了如何沿角度2使用它,但是当我尝试对图表组件进行单元测试时出现错误: Error: Error in ./ChartsComponent class ChartsComponent - inline template:1:2 caused by: AmCharts is not defined ReferenceError... -
9 votesanswersviews
Ubuntu上的Karma-Runner:'usr/bin/env: node: No such file or directory'错误
我正在尝试设置JavaScript代码测试程序Karma,但是当我运行命令初始化karma时,我得到错误'usr / bin / env:node:没有这样的文件或目录' . 我该如何解决? -
66 votesanswersviews
当业力已经安装时找不到karma命令
我使用node.js来安装业力 . 在终端上运行以下命令时,我的第一次尝试失败: npm install -g karma 那失败所以我决定使用: sudo npm install -g karma 输入密码后,它似乎正确安装 . 我正在粘贴安装输出的一部分,也许它对某人意味着什么,它将与我的问题相关 . 在所有的npm http消息之后,这就是我所看到的: > ws@0.4.27 in... -
11 votesanswersviews
使用打字稿和业力进行单元测试
我正在使用karma,jasmine,typescript为来自https://angular.io/docs/js/latest/quickstart.html的helloworld应用程序编写单元测试 . 以下是测试代码: ///<reference path="../typings/jasmine/jasmine.d.ts"/> import { M... -
0 votesanswersviews
在角度测试中注入位置
我在我的角度组件中使用位置注入将用户重定向到另一个路径 . 它按预期工作,但当我运行测试时,我收到此消息 错误:StaticInjectorError(DynamicTestModule)[CreateGroupComponent - > Location]:StaticInjectorError(Platform:core)[CreateGroupComponent - > L... -
1 votesanswersviews
Lodash在SystemJS Angular 2 app中杀死了Karma
我正在使用Lodash,“npm run start”可用于构建和启动应用程序 . 然而,当我尝试用“npm run test”运行Karma时,它会在Lodash上窒息 . 有任何想法吗? 这是错误: 404: /base/node_modules/lodash/index.js Chrome 55.0.2.883 (Windows 7) ERROR {"origina... -
0 votesanswersviews
使用jasmine运行业力时出错
我执行 karma start karma.conf.js 时收到此错误消息: > throw error('No provider for "' + name + '"!'); > ^ Error: No provider for "framework:requirejs"! (Resolving: framework:requirejs) ... -
3 votesanswersviews
显示Jasmine的Karma在浏览器中测试了AngularJs代码
我有一个工作的业力设置,它在控制台中显示我的茉莉花测试的测试结果 . 如果我启动Jasmine SpecRunner.html我得到错误“模块未定义”因此我在SpecRunner-Header中添加了angular-mock: <script type="text/javascript" src='src/public/js/libs/angular/angular-mo... -
54 votesanswersviews
ReferenceError:未定义模块 - 使用Angular / Laravel应用程序的Karma / Jasmine配置
我有一个现有的Angular / Laravel应用程序,其中Laravel充当角度前端的API,仅提供JSON数据 . 加载角度应用程序 index.php 的页面目前由Laravel提供 . 从那里开始,Angular接管了 . 我在努力开始使用Karma / Jasmine时非常困难 . 从我的项目的根目录使用 karma start 或 karma start karma.conf.js ... -
4 votesanswersviews
使用Angular设置Karma / Jasmine的问题
我正在尝试按照here和here的说明设置Karma和Jasmine以便使用我的Angular项目进行测试,但不断收到以下错误: 未捕获的TypeError:无法在/usr/local/lib/node_modules/karma-jasmine/lib/adapter.js:44中读取未定义的属性'http:// localhost:9876' 知道这个问题是什么吗?我是新手使用Karma&... -
1 votesanswersviews
Angular 2-final - Karma&Jasmine入门
我有一个Angular 2.0.0应用程序 . 但我想测试它 . 现在,我对Karma和Jasmine框架完全陌生 . 看起来目前还没有关于如何使用Karma和Jasmine测试Angular 2.0.0的最终版本的良好指南 . 现在我到了我工作的Jasmine测试部分 . 但我似乎无法让Karma工作 . 它一直在说 0/0 ERROR . 所以我在想 . 有没有人有一个关于 karma.co... -
0 votesanswersviews
Sinon不会使用参数模拟为GET提供的URL
我正在尝试为Angular应用程序中的服务开发测试并面临一些问题 . 这是服务代码: /** * Sends http request to get client states and territories available for specific vertical * * @param {number} vertical id of specific vertical. The fo... -
0 votesanswersviews
TypeError:无法读取Receiver.unmask中未定义的属性'unmask'
在Chrome浏览器中启动业力,然后在角度2中运行业力进行单位测试时,用一个错误关闭自己: 19 04 2017 19:14:27.848:ERROR [karma]:TypeError:无法在Receiver.unmask(C:\ Projects \ Git Repo \ TDP \ switchmanager \ src \ SwitchDesigner \ node_modules \ ... -
3 votesanswersviews
单元测试指令中的Angular指令
我真的很难在angularjs指令上运行业力单元测试 . 这是我的设置: var scope, ele; var template = '<div data-my-directive data="data" config="config"></div>'; beforeEach(function () { ... -
2 votesanswersviews
ngModel未使用输入值angular 2 test karma更新
我在使用角度2进行单位测试时遇到问题 . 我只想测试输入以检查我的模型是否不能超过16个字符 . (我确实在我的html中使用了maxlength) . 所以我在输入中输入一个新值,并使用dispatchEvent设置模型中的输入,但模型是更新的... 这是我的测试: /* tslint:disable:no-unused-variable */ import { EditRequestComp... -
1 votesanswersviews
使用keycloack进行角度测试“用户未登录”
我现在有一个小应用程序使用Keycloak来获得sso . 但是,当我想测试我的main.component.ts时,我遇到标准'它应该创建'测试失败的问题,我收到以下错误消息: MainComponent应该创建错误:用户未登录 下面是我的main.component.spec文件 来自'@ angular / core / testing'的import {async,ComponentFi... -
2 votesanswersviews
Angular 2单元测试/ Karma测试运行器:仅报告“包含:真实”业力测试垫片的覆盖范围
我只得到任何{included:true}文件的测试覆盖率结果,在我的例子中只有karma-test-shim.js . 我无法生成我的测试文件{included:true},因为SystemJs应该在karma-test-shim中加载它们 . 试图使我的测试文件{included:true}导致“不允许匿名系统寄存器调用”错误 . 我的测试运行良好{included:false} . 使用Sy... -
3 votesanswersviews
Angular-Cli,Webpack:为什么Karma-coverage包括lib文件夹
我们最近转向使用angular-cli beta 18.根据docs中给出的指示,我们进行了更改以运行我们的测试 . 截至目前,下面是我们的目录结构 root -coverage -src --app ---component ----mycomp.ts ----mycomp.spec.ts ---lib ----angular ----rxjs --index.html --test.ts --... -
37 votesanswersviews
如何更改Karma执行的LCOV报告的格式?
我已经将Karma配置为报告我的JavaScript代码的覆盖范围 . 以下是 karma.conf.js 文件中配置的一部分: coverageReporter: { reporters: [ { type: 'html', dir: 'build/karma/coverage' }, { type: 'lcov', d... -
18 votesanswersviews
Karma Webpack(babel-loader)ES6“意外令牌导入”
/edit: I stripped the config completely to a minimum demonstrating the problem. I also uploaded a working project to GitHub that you can checkout, so you can see for yourself. GitHub上有问题的用例:webpack-an... -
2 votesanswersviews
Karma测试在chrome中失败但是通过了phantomjs
我现在一直在与此斗争,似乎无法找到正确的解决方案, 我正在运行一个使用角度2的测试环境的离子2项目,当我使用karmas chrome启动器运行测试时,我收到以下错误: 开始: 07 12 2016 11:20:50.590:INFO [业力]:Karma v1.2.0服务器始于http://localhost:8888/ 07 12 2016 11:20:50.591:INFO [launche... -
1 votesanswersviews
Ionic 3和Angular 4 - Karma不会立即运行单元测试 . 开始需要一分钟或更长时间 . 什么导致缓慢?
使用Ionic 3和Angular 4 - Karma Test Runner不会立即运行单元测试 . 开始需要大约一分钟或更长时间 . 这是正常的还是我可以做些什么来加快速度? This image shows the delay 以下是我正在使用的业力配置文件 module.exports =(config)=> { var testWebpackConfig = require('... -
15 votesanswersviews
角度6和业力'Can not load “@angular-devkit/build-angular”, it is not registered'
我不得不迁移到最新的角度版本 . 在此之后,业力测试停止工作,并继续使用错误日志粉碎: 14 04 2018 14:17:00.453:ERROR [preprocess]:无法加载“@ angular-devkit / build-angular”,它未注册!也许你错过了一些插件? ... \ parkandrest的UI \ node_modules \ @角的devkit \集结角的\ s... -
4 votesanswersviews
如何配置Karma以包含angular-cli项目的全局scss文件?
我无法配置angular-cli scss业力来测试我的组件 . 运行 ng test kamra单元测试仅包括组件自己的scss样式 . 为了在测试中应用我的主要styles.scss,我尝试在karma.conf.js中配置它们: files: [ { pattern: './src/test.ts', watched: false }, { pattern: './src/sty... -
7 votesanswersviews
在Angular 2的构造函数中注入了Router的故障单元测试服务
我在AngularConnect conf 2015(及其存储库:https://github.com/juliemr/ng2-test-seed)中提出了建议,我正在使用Karma和Jasmine . 它遵循要测试的示例服务: import { Router } from 'angular2/router'; export class ExampleService { constructo... -
101 votesanswersviews
安装后运行业力导致'karma'无法识别为内部或外部命令
在使用安装业力之后,我正试图将业力作为角度种子项目的一部分运行 npm install -g karma 我明白了: 'karma' is not recognized as an internal or external command, operable program or batch file. 当我试图从angular-client \ scripts运行test.bat时,该文件的... -
2 votesanswersviews
无法使用Angular-cli运行Karma
我遇到了一个奇怪的问题,发生在我的某个项目中,即使使用完全相同的设置也无法在其他项目中重现它 . 每次我尝试运行 ng test 或别名 npm test 我都会收到两个模块丢失的错误( karma-jasmine-html-reporter & karma-coverage-istanbul-reporter ) . 虽然这些模块肯定存在!例如: web-app@0.0.3-alpha tes... -
125 votesanswersviews
未定义Angular返回模块中的测试服务
我正在尝试在我的项目中运行默认服务单元测试(取自GitHub上的Angular Seed项目),但我一直收到错误“模块未定义” . 我已经读到它可能与referenced JavaScript files的顺序有关,但我似乎无法让它工作,所以希望你们中的一个可能能够提供帮助 . 我的测试配置如下所示: basePath ='../'; files = ['public / javascripts... -
2 votesanswersviews
带有RequireJS的Karma加载规范但不加载src和lib文件
我正在使用带有requirejs,coffeescript,jasmine和jasmine-sprockets的业力0.10.9(因为我正在研究一个RoR项目,我们有一些只包含sprockets指令的文件) . 当我开始业力时,我得到“执行0 0错误”消息 . 看起来在跑步者页面(localhost:9876)上,lib和src文件没有加载,但规格确实如此 . 控制台中没有错误 . 当我将lib或...