karma-mocha

Karma can't load webpack

人走茶凉 提交于 2020-01-13 09:47:11
问题 I'm getting this error; 16 07 2015 13:03:52.741:WARN [preprocess]: Can not load "webpack"! Error: Can not resolve circular dependency! (Resolving: preprocessor:webpack -> webpackPlugin -> preprocessor:webpack) My karma.conf looks like; var webpack = require('webpack'); module.exports = function (config) { config.set({ browsers: [ 'Chrome' ], //run in Chrome singleRun: true, //just run once by default frameworks: [ 'mocha' ], //use the mocha test framework files: [ 'tests.webpack.js' //just

Error “step is not defind” using Mocha Test and what is mean by “Then simply run mocha with --require mocha-steps” in tutorial

丶灬走出姿态 提交于 2020-01-11 13:07:13
问题 `describe('my smoke test', function() { step('login', function() { vdriver.wait(until.elementLocated(By.name('UserName'))).sendKeys("aqdjska@gmail.org"); driver.wait(until.elementLocated(By.id("mat-input-3"))).sendKeys("cool123"); driver.sleep(2000); driver.wait(until.elementLocated(By.css(".mat-progress-spinner-light > div"))).click(); }); step('Open Apps', function() { driver.wait(until.elementLocated(By.xpath("//span[contains(text(), 'Apps')]"))).click(); driver.wait(until.elementLocated

Explain karma unit test times

血红的双手。 提交于 2019-12-31 02:36:28
问题 I've been searching the web for this for two days and I found nothing. Maybe I'm looking in the wrong way — I don't know... So here it is: what are the times on my console when running a Karma+Jasmine+phantomJs unit test? ... Executed 1 of 1 SUCCESS (0.878 secs / 0.112 secs) First, I though that the second time is the total unit test time (for example, when running multiple tasks), however, sometimes the first time gets to be 'bigger', sometimes not... Anyone? 回答1: total time / net time net

Dealing With Dependencies in angularjs Testing

拟墨画扇 提交于 2019-12-25 03:59:16
问题 This is for work (I have permission) so I can't post exact code. So I have to test controllers of a large module. The module has a large config function with a bunch of controllers for the logic of the different pages. For the actual application it's loaded with bower, which is irritating since I'm testing with Karma-Browserify and npm. So the the dependencies are a mess. I basically have to import everything that was loaded from bower.json to package.json. This is my karma.conf.js: module

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

Jasmine angular unit test 'Cannot read 'property' of undefined

烈酒焚心 提交于 2019-12-24 02:06:20
问题 I have just started learning angular unit testing. However, this test on a function with http call fails. I have pin pointed the problem but however I am not being able to fix it. I know it's some simple issue Controller //Get data from URL vm.getJson = function() { var url = 'https://www.reddit.com/r/worldnews/new.json', count = 0; $http.get(url).success(function(response) { console.log(response); for (var i = 0; i < response.data.children.length; i++) { vm.data.push(response.data.children[i

chai is not defined in Karma-mocha

元气小坏坏 提交于 2019-12-22 07:06:38
问题 I am running my test cases succesfully using mocha-phantomjs configurations. Now I am running these test using Karma launcher. But I get the issue Chai is not defined . Here is my configuration file. module.exports = function(config) { config.set({ client: { mocha: { ui: 'tdd' } }, basePath: '', frameworks: ['mocha'], files: [ 'web/js/*.js', 'test/lib/*.js', 'node_modules/chai/chai.js' //added this on suggestion of the answer in stackoverflow ], exclude: [ ], preprocessors: { }, reporters: [

Mocha unit tests running with Karma - done() is not defined

℡╲_俬逩灬. 提交于 2019-12-22 04:07:58
问题 I'm trying to get tests written with Mocha to work running Karma, and they sort of work, but I cannot use the done() method to implement async tests, which essentially makes the tools useless to me. What am I missing? karma.conf.js module.exports = function(config) { config.set({ basePath: '../..', frameworks: ['mocha', 'requirejs', 'qunit'], client: { mocha: { ui: 'bdd' } }, files: [ {pattern: 'libs/**/*.js', included: false}, {pattern: 'src/**/*.js', included: false}, {pattern: 'tests/mocha

undefined is not an object in Angular.js service

守給你的承諾、 提交于 2019-12-14 03:24:41
问题 I have a method like this in my service angular.module('App') .factory("AppService", [function() { var _admin; return { get admin() { return _admin; }, }; }]); In my controller i am using it like this: $scope.show = function(){ return AppService.admin === 0 || (AppService.admin !== 0 && AppService.admin === true); }; When i am trying to test the function , i am getting an error like below: it('calls the showAutoPay method', function () { $scope.show(); expect($scope.show).to .have.been

Karma + Webpack + sourcemap preprocessor doesn't stop at breakpoints in WebStorm

梦想的初衷 提交于 2019-12-13 18:13:21
问题 I'm starting a project the NG6-Kit-starter. I'm using WebStorm. I want to be able to debug my unit tests using WebStorm, so I followed this tutorial. I can run unit test from WebStorm but I can't put breakpoints, it never stops at breakpoints and I have don't know why. I suspect it has to do something with the fact that I'm using a preprocessor in my karma config file. preprocessors: { 'spec.bundle.js': ['webpack', 'sourcemap'] }, See below my full karma.config.js module.exports = function