jasmine

Jasmine.js: Race Conditions when using “runs”

血红的双手。 提交于 2019-12-10 22:30:29
问题 I have noticed a strange behaviour when testing my code with jasmine. One test fails when executed together with the other tests in my spec. When called alone the test passes. The test asserts the script A.js that depends on script B.js which offers the method "Create". I create inside the test a spy for the "Create" and invoke script A.js (A.init) that will load some data (loadData with returns again a promise) and then call the "Create" method 5 times (once the loadData-promise is resolved)

Karma/Jasmine Issues w/ Angular2 Project

冷暖自知 提交于 2019-12-10 22:27:55
问题 I have a project that looks like: I am trying to get Karma/Jasmine working as the test framework. I tried replicating this project: https://github.com/juliemr/ng2-test-seed, modifying it to my needs. I have a mock test in test folder that I am trying to get to run. Though, when I try to do the npm run test this is what I get: I am not sure if my file paths are correct in the karma-test-shim.js / karma.conf.js as I'm still relatively new to working with npm/node projects. Here is my karma-test

Converting angular-seed jasmine unit tests to coffeescript

牧云@^-^@ 提交于 2019-12-10 21:27:49
问题 As an exercise, I am trying to convert the karma unit tests included in the angular-seed repo from js to coffee script. In particular, I am having problems with the tests/unit/directivesSpec.js test set, which defines a simple value service. Here is my coffee script code: 1 describe 'directives', -> 2 beforeEach module 'myApp.directives' 3 4 describe 'app-version', -> 5 it 'should print current version', -> 6 module ($provide) -> 7 $provide.value 'version', 'TEST_VER' 8 inject ($compile,

Protractor/Jasmine showing different versions - what am I doing wrong?

社会主义新天地 提交于 2019-12-10 21:06:08
问题 When I do this: console.log('jasmine-version:' + jasmine.getEnv().versionString()); it prints: jasmine-version:1.3.1 revision 1354556913 When I run 'npm list jasmine-core' it prints: server@0.0.1 /Users/xx/Desktop/workingDirectory └── jasmine-core@2.1.3 Why is one showing 2.1.3 and another showing 1.3.1? I don't seem to have the features in 2.1.3, so it's running 1.3.1. How do I fix this? 回答1: You have to specify that you want to use jasmine2 in the conf file. Please read the docs here: https

How to set up JASMINE using MAVEN-PLUGIN?

让人想犯罪 __ 提交于 2019-12-10 20:28:37
问题 I have a folder structure like -root -pom.xml -service -web -pom.xml -src -main -test -java -javascript -lib -specRunner.js -runner.html -spec -model -view -collection I have written JASMINE test cases in the "spec" folder containing "model","views","collections". I'm able to see my test results in runner.html. Now i'm trying to integrate with MAVEN build. SO followed steps given in http://searls.github.io/jasmine-maven-plugin But i'm getting build failure when doing mvn clean install and

Mocking Angular Material Dialog afterClosed() for unit test

喜你入骨 提交于 2019-12-10 19:09:27
问题 I am opening my mat-dialog with the following function: accept() { let dialogRef = this.dialog.open(AcceptDialogComponent, { data: { hasAccepted: false } }) dialogRef.afterClosed().subscribe(result => { console.log(result); if (result.hasAccepted === true) { this.leadService.acceptLead(this.holdingAccountId, this.lead.id) .pipe( takeUntil(this.onDestroy$) ) .subscribe (acceptLeadRes => { console.log(acceptLeadRes); this.leadService.updateLeadAction('accept'); }, (err: HttpErrorResponse) => {

How to call a function in another function in protractor

时光总嘲笑我的痴心妄想 提交于 2019-12-10 18:46:36
问题 first function describe('Shortlisting page', function () { it('Click on candidate status Screened', function () { element(by.css('i.flaticon-leftarrow48')).click(); browser.sleep(5000); browser.executeScript('window.scrollTo(0,250);'); element(by.partialButtonText('Initial Status')).click(); browser.sleep(2000); var screen = element.all(by.css('[ng-click="setStatus(choice, member)"]')).get(1); screen.click(); element(by.css('button.btn.btn-main.btn-sm')).click(); browser.executeScript('window

How to unit test an Angular 1.5 Component template?

隐身守侯 提交于 2019-12-10 18:05:42
问题 So, here's my test: describe('My Test', function(){ var $componentController, $compile, controller, scope; beforeEach(inject(function($injector, $rootScope, $templateCache){ $templateCache.put('my-component.html', '<h1>{{ $ctrl.foo }}</h1>'); $componentController = $injector.get('$componentController'); var bindings = { foo: 'A Foo' }; scope = $rootScope.$new(); controller = $componentController('myComponent', { $scope: {} }, bindings); })); it('should render the correct html', function(){

Error: No provider for Compiler! DI Exception Angular 2 Testing

倾然丶 夕夏残阳落幕 提交于 2019-12-10 17:55:36
问题 The given unit test throws error when executed using npm test command. It says there was a DI Exception with error message "Error: No provider for compiler!" import {TestComponentBuilder} from "@angular/compiler/testing"; import { expect, it, describe, async, inject, beforeEach, beforeEachProviders } from "@angular/core/testing"; import {provide} from '@angular/core'; import {TestService} from "../services/Test.service"; import {TestComponent} from "./Test.component"; describe('Component:

Spec for async functions using Jasmine

不问归期 提交于 2019-12-10 17:46:06
问题 When I'm trying to test _.debounce function like in this qunit test using jasmine something strange happens. Seems like it could be tested using jasmine.Clock.useMock() ... But when I write: it('_.debounce()', function () { var spy = jasmine.createSpy('debounce'), debouncedSpy = _.debounce(spy, 100); jasmine.Clock.useMock(); // direct calls debouncedSpy(); debouncedSpy(); debouncedSpy(); // timed out calls setTimeout(debouncedSpy, 60); setTimeout(debouncedSpy, 120); setTimeout(debouncedSpy,