当使用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
我正在为我的角2应用程序编写单元测试,我正在尝试测试我制作的组件。我指的是一个示例git存储库,用于使用TypeScript和Jasmine框架在Range2中编写测试用例。为了测试我的组件,我做了样例存储库()中所做的同样的工作,但是我得到了以下错误。
TypeError: Cannot read property 'firstChild' of null
at Object.el (http://127.0.0.1:9090/node_modules/angular2/bundles/testing.dev.js:537:29)
at TestComponentBuilde
当我为我正在处理的离子项目运行单元测试时,我从AppComponent得到了这个错误,并且它发生在两个单元测试上: App component should create the app
TypeError: this.platform.is is not a function 和 App component should initialize the app
TypeError: this.platform.is is not a function 下面是我的app.component.spec.ts的代码: import { HttpClientTestingModule} fr
我为我的Angular应用程序写了一些单元测试,当我运行ng test时,它们都通过了,这很棒。但是,测试仍然被认为是不成功的,因为在结束时抛出了一个错误:
An error was thrown in afterAll
TypeError: env.catchExceptions is not a function
经过一些研究后,我发现所有的是说要降级到jasmine 2.99,但它对我不起作用。
我正在使用Angular 10,并使用Jasmine和Karma进行测试。
我有一个reactjs组件,该组件内部有一个函数。我想为此编写单元测试用例。下面是我的样例单元测试用例。函数名称为getNewGroupName
describe("CreateGroupName component", () => {
it("Correct Copy name should be generated for first copy", () => {
component = ReactTestUtils.renderIntoDocument( < CreateGroupName reactor
我正在开发一个使用自定义指令的AngularJS应用程序。我还试图在我的应用程序中使用单元测试。所以,我想利用茉莉花。目前,我的单元测试是问题所在。目前,它看起来如下:
myDirective.spec.js
describe('Directive: myDirective', function () {
describe('Function: myProcedure', function () {
it('should word', function ($rootScope, $compile) {
var e
在我的离子应用程序上运行单元测试时,在app.component.spec.ts中,它测试应用程序是否初始化,我得到了以下错误: AppComponent should initialize the app
Uncaught Error: Uncaught (in promise): TypeError: Cannot read property 'getToken' of undefined
TypeError: Cannot read property 'getToken' of undefined
Failed: Uncaught (in promi
在用jasmine编写单元测试时,我遇到了一个问题,我已经成功地将其提炼为一个非常基本的测试场景:
describe('weird shit', function () {
var myVal;
beforeEach(myVal = 0);
it('throws for some reason', function () {
expect(myVal).toBe(0);
});
});
这会抛出一个TypeError:
Test 'weird shit:throws for some reason'
我试图在Angularjs中测试一个负责文件上传的控制器方法:
$scope.uploadFile = function() {
var fd = new FormData();
for (var i in $scope.files) {
fd.append("uploadedFile", $scope.files[i]);
}
var xhr = new XMLHttpRequest();
xhr.addEventListener("load", $scope.uploadComplete, false
在单元测试中,我在访问服务和过滤器时遇到了困难(我还没有尝试指令)。我以前写过单元测试,但是当我转向构建的配置时,我在访问我们的新服务编写单元测试时遇到了困难。我不断地得到TypeError: null is not an object (evaluating 'currentSpec.$modules') in...。我做了一些阅读,看起来这可能与我正在使用的节点包有关。我想知道更大的社区是否能够确保这些配置看起来正确。我把下面的文件缩略下来了。
对于当前的配置,这是错误的。
package.json
"devDependencies": {
"a
我想为我的Angular v9应用程序使用Jasmine和CucumberJS进行单元测试。在tutorial from cucumber.io之后,我将cucumber设置为默认的runner。但是不能使用jasmine方法。我知道如何使用expect方法,但需要访问茉莉库的其余部分,如spyOn和createSpyObj。当我执行line:expect(this.actualAnswer).toBe(expectedAnswer);错误时抛出TypeError: Cannot read property 'toBe' of undefined at World.<a
当我在模块中定义组件时,我不能让我的单元测试在Angular.js中工作。这是我使用Karma test runner和Jasmine进行的单元测试。我看过几篇文章,看起来这是测试模块控制器的方法。但是,我的测试运行器输出显示‘模块未定义’。我不确定我错过了什么。我需要在karam.conf.js中配置一些东西吗?
describe('bulkEditor factories', function() {
beforeEach(module('BulkEditor'));
it('should see the controller
我有一些jasmine单元测试,它们是“集成测试”,用于测试一些核心组件,这些组件是作为angular服务编写的。但我的组件不会调用web。我演示这个问题的两个测试是这样的:
顺便说一句,我有一个禁用CORS的插件
it('test http get', function () {
httpGet('http://endpoint.json');
function httpGet(theUrl) {
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
我试图在我的角度应用程序中使用Jasmine进行一些单元测试,但我面临一些错误。
误差
Error: [$injector:modulerr] Failed to instantiate module LocalStorageModule due to:
Error: [ng:areq] Argument 'fn' is not a function, got string
Spec
describe("testing the controller", function () {
var $controllerConstructor;
var sc
你好,堆栈溢出社区,
我在用Angular 5编写一个简单的Jasmine单元测试来验证组件的DOM中是否存在元素时遇到了问题。我对标准的HTML元素进行了成功的测试,比如p:expect(fixture.debugElement.query(By.css('p')).nativeElement).toBeTruthy();
但是,这会导致TypeError:无法读取角度组件的null属性'nativeElement‘。举个例子,一个电影组件,它的选择器是app- Movie:
it ('should have a element selector called