karma-runner

how to access controller in directive [jasmine]

女生的网名这么多〃 提交于 2019-12-24 06:45:12
问题 I am having some difficulty accessing the methods and variables on a directive in order to test it. What am I doing wrong? I have attached my directive and the test file. I did not include my karma conf because I know it is correct and that is not the problem. accountsearch.spec.js <-- this is the file with test cases describe("Account search directive logic tests", function (){ var element,$scope,scope,controller,template beforeEach(module("Common.accountSearch")) beforeEach(inject( function

PhantomJS set browser timezone setting

主宰稳场 提交于 2019-12-24 06:26:04
问题 I am running Karma with PhantomJS to run some unit tests. In my unit tests there are some tests which do some date comparison which all pass when run locally. Our build server is on a different timezone and the date tests are failing due to different timezones. I looked at phantomjs options to and didn't see any option regarding locale or timezone. Is it possible to configure phantomJs to the same timezone on every computer even though they are different timezones ? 回答1: If you're running it

Karma tests using a Docker image of Chrome

寵の児 提交于 2019-12-24 04:41:14
问题 For tests on CI server I want to use an image of Chrome instead of PhantomJS. I can do this with and without puppeteer but both require me to install chrome-stable package on the server. Thus I want a more lightweight method hence the use of the docker image. For Karma, according to the docs, I must specify a script for the browser if i want to use a custom browser. Also Karma will pass 1 argument to this script, the url. For this requirement I also pulled the browserless docker image

Speed up tests run in Chrome

你说的曾经没有我的故事 提交于 2019-12-24 03:33:32
问题 This is based on this question where it was discovered that when Chrome is not in the foreground, the tests run really slow. Anyone know how to get around that so I can continue to use Chrome, but don't have to keep it in the foreground? 回答1: Run chrome in headless mode. I've seen a fantastic performance improvement. gulp.task('test-headless-chrome', function (done) { process.env.DISPLAY=':95'; withXvfb(function(stop) { server.start({ configFile: __dirname + '/../karma/karma.conf.js',

Unit testing a service in angularJS

◇◆丶佛笑我妖孽 提交于 2019-12-24 03:20:23
问题 I'm relatively new to unit testing but was now tasked to write tests for a existing code base that I know quite well. Sadly I'm unable to achieve any progress what so ever nor find really helpful documentation. The main component of the code base is a service to retrieve data from an api but I'm unable to get an instance of the module the service belongs to: TypeError: module is not a function in /home/faebser/workspace/GridSense-CMS-App/dev/test/unit/api.test.js (line 13) karma config: http:

How to properly unit test ReactDOM.render with Karma and PhantomJS?

落爺英雄遲暮 提交于 2019-12-24 02:29:05
问题 Say I have the following on Index.tsx : ReactDOM.render( <h2 style={{textAlign: "center"}}>Hello World</h2>, document.getElementById("wrapper") ); First, how exactly do I unit test ReactDOM.render call? Second, running this on Karma + PhantomJS, I get the following error: Invariant Violation: _registerComponent(...): Target container is not a DOM element. at /tmp/karma-typescript-bundle-192osSfGKwYIxIW.js:188 This is because document.getElementById("wrapper") will not work under PhantomJS

log4js and winston loggers conflicting when trying to run karma from ionic cli

喜你入骨 提交于 2019-12-24 02:17:28
问题 I'm trying to run karma as a webpack plugin. This is just: var Server = require('karma').Server; new Server({ configFile: config, singleRun: true }, doneCallback }).start(); The outer ionic-cli package is using winston logger while karma uses log4js and I assume they're conflicting so as a result I'm getting errors like: 24 02 2016 00:54:52.530:ERROR [karma]: [TypeError: Can't call method on undefined] TypeError: Can't call method on undefined at TypeError (native) at module.exports (/Users

Cannot install jasmine-core on Windows 7 / OSX

心已入冬 提交于 2019-12-23 16:04:40
问题 I am trying to install karma-jasmine on Windows 7 / Git Bash, according to these guidelines: http://karma-runner.github.io/0.13/intro/installation.html However, the installation fails for jasmine-core : $ npm install karma-jasmine karma-chrome-launcher --save-dev npm WARN install Couldn't install optional dependency: Unsupported ngut@1.0.0 g:\SW Engineering\ngUT ├── UNMET PEER DEPENDENCY jasmine-core@* ├─┬ karma-chrome-launcher@0.2.2 │ ├─┬ fs-access@1.0.0 │ │ └── null-check@1.0.0 │ └─┬ which

Testing | Cannot read property 'assertPresent' of undefined at resetFakeAsyncZone

被刻印的时光 ゝ 提交于 2019-12-23 13:09:12
问题 I have a problem with karma v1.4. testing framework. All my unit tests are now failing with error Cannot read property 'assertPresent' of undefined at resetFakeAsyncZone I've already searched for solutions and tested them, but unfortunately none helped. The solutions suggests that I should change the order of imports in my test.js file. I've done that. This is the suggested order I am using, but it still fails: import 'zone.js/dist/zone.js'; // 1st import 'zone.js/dist/async-test'; // 2nd

TypeError: 'undefined' is not a function (evaluating 'mockBackend.expectPost(

六眼飞鱼酱① 提交于 2019-12-23 12:56:04
问题 I am trying to unit test an angularjs controller with Karma, and jasmine. Here is my test suite: describe('Controllers', function(){ var $scope, ctrl; beforeEach(module('curriculumModule')); describe('CreateCurriculumCtrl', function(){ var mockBackend, location; beforeEach(inject(function($rootScope, $controller, _$httpBackend_, $location){ mockBackend = _$httpBackend_; location = $location; $scope = $rootScope.$new(); ctrl = $controller('CreateCurriculumCtrl', { $scope: $scope }); })); it(