jasmine

Requiring timeouts when testing Meteor with Velocity and Jasmine

南笙酒味 提交于 2019-12-04 11:05:32
Pretty new to meteor, velocity and jasmine so not sure if I am doing something wrong, using Jasmine for something it's not designed for, or this is just the way it works. I am finding I need to set timeouts for pretty much all of my tests in order to get them to pass. Should this be the case or am I doing something incorrectly? For example some tests I am running to check validation messages: describe("add quote validation", function() { beforeEach(function (done) { Router.go('addQuote'); Tracker.afterFlush(function(){ done(); }); }); beforeEach(waitForRouter); it("should show validation when

Protractor expectation that element is eventually present

烂漫一生 提交于 2019-12-04 10:58:25
Is there a way to have an expectation that an element is eventually on the page? e.g. a way for browser.wait(protractor.ExpectedConditions.presenceOf(element(by.partialLinkText('Continue'))), 1000, 'Unable to find continue link'); to fail with an expectation error instead of a timeout? Essentially a way to have a isEventuallyPresent() instead of isPresent() in the line below expect(element(by.partialLinkText('Continue')).isPresent()).toBe(true); For reference, I'm using browser.ignoreSynchronization = true even though it's an Angular app, and using Jasmine (at least for now). Using the facts

How to unit test a FormControl in Angular2

☆樱花仙子☆ 提交于 2019-12-04 10:03:06
问题 My method under test is the following: /** * Update properties when the applicant changes the payment term value. * @return {Mixed} - Either an Array where the first index is a boolean indicating * that selectedPaymentTerm was set, and the second index indicates whether * displayProductValues was called. Or a plain boolean indicating that there was an * error. */ onPaymentTermChange() { this.paymentTerm.valueChanges.subscribe( (value) => { this.selectedPaymentTerm = value; let returnValue = [

Angular 5 Jasmine Error: Expected one matching request for criteria found none

蓝咒 提交于 2019-12-04 09:47:58
I have a very simple service call and a jasmine test for it. Service call: myServiceCall(testId: number) : void { const url = `${this.url}/paramX/${testId}`; this.http.put(url, {},{headers: this.headers}).subscribe(); } My Test Method: it('should call myServiceCall', inject([MyService], (service: MyService) => { let testId = undefined; service.myServiceCall(testId); let req = httpMock.expectOne(environment.baseUrl + "/paramX/123"); expect(req.request.url).toBe(environment.baseUrl + "/paramX/123"); expect(req.request.body).toEqual({}); req.flush({}); httpMock.verify(); })); I get of course an

Mocking $routeParams in a test in order to change its attributes dynamically

久未见 提交于 2019-12-04 09:44:02
I have a controller test that depends on the Angular $routeParams service: var $routeParams, MainCtrl, scope; beforeEach(inject(function ($controller, $rootScope, $injector, $templateCache) { scope = $rootScope.$new(); $routeParams = $injector.get('$routeParamsMock'); MainCtrl = $controller('MainCtrl', { $scope: scope, $routeParams: $routeParams, }); })); it('should load a pg from $routeParams', function(){ scope.userData = {}; $routeParams._setPg('PG_FIRST'); scope.$digest(); timeout.flush(); expect(scope.userData.pg).toBe(0); $routeParams._setPg('PG_SECOND'); scope.$digest(); timeout.flush()

Protractor with Firefox (32 latest) browser not loading

末鹿安然 提交于 2019-12-04 09:37:39
So for some reason, when I run protractor, Firefox (32 latest) just opens with an empty browser and doesn't navigate to the baseURL. The tests I have written work fine with chrome, but not with firefox. It probably has something to do with the way the conf file is set up. Any ideas? Conf file: exports.config = { allScriptsTimeout: 11000, specs: [ 'e2e/*.js' ], multiCapabilities: [ { 'browserName': 'firefox' }, { 'browserName': 'chrome' } ], chromeOnly: false, chromeDriver: 'e2e/chromedriver/', baseUrl: 'http://localhost:9000/', framework: 'jasmine', jasmineNodeOpts: { defaultTimeoutInterval:

When should I use $provide versus Jasmine Spies in my Angular JS Unit tests

倖福魔咒の 提交于 2019-12-04 09:21:52
问题 I work on a large Angular App and initially we done a lot of our tests by using $provide to mock services. However we now have a lot of Jasmine Spies in our tests in order to stub and spy on services. i.e spyOn(myService, 'myMethod').andReturn 'myValue' Should we really be using $provide for this or are there cases where spying on a service is the best approach? In the Angular Tests they use spies for spying on Jquery which I would see as an external service. spyOn(jq.prototype, 'on');

Is there a generator for jasmine angular controller tests?

回眸只為那壹抹淺笑 提交于 2019-12-04 09:01:05
问题 I'm looking for something that generates a boilerplate jasmine test for an angular controller. It seems you could pull the dependencies for the controller out and drop them into the spec and save some typing. I would be shocked if I were the first person to have this idea but I'm unable to find anything that does this, save a yeomen project that doesn't appear to work. 回答1: I've recently published my version of Angular JS unit test generator on npm - tleaf. Basically it tries to parse you

Running tests .mjs / ESM on Node using Jasmine or any other alternative

梦想的初衷 提交于 2019-12-04 08:08:20
My Node-based project is implemented using native ES module support on Node thanks to the --experimental-modules CLI switch (i.e. node --experimental-modules ). Obviously, when I run a spec using Jasmine node --experimental-modules ./node_modules/jasmine/bin/jasmine I get the following error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module Is it ever possible to use Jasmine using ES modules in Node? If not, is there any alternative to don't use a framework (e.g. running tests with npm scripts)? It was easier than I thought. It's just about calling a file which you might call run.mjs

How use require inside a spec - grunt + karma + jasmine in node

∥☆過路亽.° 提交于 2019-12-04 07:56:31
Vague version question: How can I use require inside a spec with grunt? Context: I'm working on an existent node project that has no tests yet, so I read some and realized to use karma and jasmine. I read some tutos (including these): http://kwilson.me.uk/blog/use-karma-and-grunt-to-run-your-jasmine-tests-in-real-time/ http://ahexamples.blogspot.com.br/2014/03/example-of-jasmine-karma-sonar-grunt.html So I'm trying to run my specs with grunt and getting this error: X encountered a declaration exception ReferenceError: Can't find variable: require in file:///(...)-spec.js (line 2) (1) The line