jasmine

Can't find variable: loadFixtures

老子叫甜甜 提交于 2019-12-11 13:22:09
问题 I am using karma, jasmine and phantomjs for my project and when I am executing start karma; I am getting following error: PhantomJS 1.9.7 (Linux) View:: Login guestRegistration Should call the guestRegistration event when btn-grey is clicked FAILED ReferenceError: Can't find variable: loadFixtures at /apps/devops/jenkins/home/jobs/UIMod-Jasmine-Karma/workspace/WebContent/test/javascript/spec/login.view.spec.js:84 ReferenceError: Can't find variable: spyOnEvent at /apps/devops/jenkins/home

how to mock ngModel?

北城余情 提交于 2019-12-11 13:17:17
问题 So I am testing a controller, which is referencing a property specified as ngModel in DOM. But while I am testing my controller, I don't have the template. So whenever $scope.foo.property is being accessed in the controller, it throws an error. 回答1: In your test, you can define your property before instantiate your controller : it('should mock ng-model', inject(function($rootScope, $controller) { $rootScope.foo = { property: 'mock value' }; $controller('myController', {$scope: $rootScope}); }

protractor “ERROR - Unable to start a WebDriver session”

荒凉一梦 提交于 2019-12-11 13:15:00
问题 I have some it tests on my single-page-app written in angular. the tests are in protractor. they ran during the build before, but now that I moved all of them to a branch something got broken and when I run the tests I'm getting: Running "protractor:normal" (protractor) task Starting selenium standalone server... [launcher] Running 1 instances of WebDriver Selenium standalone server started at http://172.31.9.226:23730/wd/hub ERROR - Unable to start a WebDriver session. c:\projects\blog

How to debug HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR { “isTrusted”: true } in Angular 6 unit test?

狂风中的少年 提交于 2019-12-11 12:35:32
问题 When I run my test suite, I get an error in a totally different unit test than the one I've been working in. What am I doing wrong? HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR { "isTrusted": true } It is then followed by some build steps and the following error during test execution: HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR An error was thrown in afterAll [object ErrorEvent] thrown If I comment out certain tests, say in class A, another test fails in Component B. If I comment those out, another

Mock for Stripe error in Jasmine tests?

本秂侑毒 提交于 2019-12-11 11:56:46
问题 The following code is raising an error in the test environment because StripeCheckout is not defined: var handler = StripeCheckout.configure({ key: 'pk_test_...', image: '/images/marketplace.png', token: function(token) { process(token); } }); How to create a Stripe Mock? I thought something like this might work: function StripeMock(){ } StripeMock.prototype.configure = function( config ){ console.log('configure'); } var StripeCheckout = new StripeMock(); But I get TypeError: 'undefined' is

How can I navigate to failed Karma tests in WebStorm?

喜你入骨 提交于 2019-12-11 11:40:33
问题 I'm able to run my Karma test suite from within WebStorm, using a Karma Run Configuration. After the tests run, the failed ones are shown in a tree on the left side. I would expect that I could click/double-click on a test name and be taken to the source code for the test, but that doesn't happen. I'm pretty sure I've seen this work in a video before. How can I turn it on? I looked at the documentation here but it wasn't very helpful: http://www.jetbrains.com/webstorm/webhelp/test-runner-tab

Why is using jasmine's runs and waitFor function necessary?

爱⌒轻易说出口 提交于 2019-12-11 11:16:29
问题 I'm testing an asynchronous piece of code with something that looks like this: randomService.doSomething().then(function() { console.log('I completed the operation!'); }); Surprisingly (to me) I've found that it only succeeds (ie console.log output is shown) when wrapped inside jasmine's runs function, like so: var isDone = false; runs(function() { randomService.doSomething().then(function(data) { console.log('I completed the operation!'); isDone = true; }); }); waitsFor(function() { return

Why is Jasmine not executing it() on this async test?

好久不见. 提交于 2019-12-11 10:58:15
问题 I'm trying to test a prototypal method that returns insights about a dataset I am loading via AJAX. $.getJSON('../data/bryce.json').done(function(data) { insights = new Insights(data); describe("People Method", function() { console.log('it executes this far'); it("should return complete people data", function() { console.log('but not this far'); expect(insights.people()).toBeTruthy(); }); }); }); When I run this test suite, describe() executes, but not it(). I'm pretty new to JavaScript

How to exclude some spec files in jasmine?

无人久伴 提交于 2019-12-11 10:47:47
问题 Is there any way to exclude some spec files with in a directory in jasmine? For example, I want to exclude all spec in the extended folder from Foo folder. ``` ├── Foo │ ├── sub | | | | | |--extended │ │ ├── a-spec.js | | ├── e-spec.js │ ├── b-spec.js │ ├── c-spec.js │ ├── d-spec.js └── ``` I have tried with folowing jasmin.json.But this is not working. { "spec_dir": "Foo/", "spec_files": [ "**/*[sS]pec.js", "!**/extended/*.js" ] } 回答1: You can get information regrading this issue on jasmine

Testing window.postMessage directive

混江龙づ霸主 提交于 2019-12-11 10:39:28
问题 I'm having trouble testing my directive which enables cross-document messaging by registering a message handler: .directive('messaging', function ($window, MyService) { return { link: function () { angular.element($window).on('message', MyService.handleMessage); } }; }) All I want to unit test is that when this directive is compiled, and window.postMessage('message','*') is called, my message handler should be called: http://jsfiddle.net/mhu23/L27wqn14/ (including jasmine test) I'd appreciate