karma-runner

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: [

test not running on karma/jasmine/require.js 'There is no timestamp for *lib*!' error

空扰寡人 提交于 2019-12-22 06:47:15
问题 I change the code, extend some functionality and add new unittest for that. Now, when I run my unit tests with karma (test framework - jasmine ), it throw me an error 'There is no timestamp for /libs/angular-bootstrap/ui-bootstrap-tpls.js!' Uncaught Error: Script error for: angular-bootstrap http://requirejs.org/docs/errors.html#scripterror at http://localhost:9876/base/node_modules/karma-requirejs/lib/require.js?1379984163000:138 What I'm doing wrong? 回答1: It was my mistake completely. when

Angularjs injected controller empty when testing with Jasmine

江枫思渺然 提交于 2019-12-22 06:32:25
问题 I am currently working with Angular and using Karma and Jasmine to make the testing. The filters, for example are injected to the main module and can be tested without any problem, but when I try to test the controllers I get an empty object after the injection. Here is the code of my main module: (function () { 'use strict'; var dependencies = []; angular.module('myApp', dependencies) }()); The controller that I am to test: (function () { 'use strict'; angular.module('myApp') .controller(

How can I get Karma + Webpack to find the module?

℡╲_俬逩灬. 提交于 2019-12-22 06:28:59
问题 I want to run my tests on a bunch of modules after webpack has combined them together through the Karma test runner, but whenever I run my tests Karma says, "Error: Cannot find module "hello.js" at http://localhost:9877/base/src/hello.spec.js?d301966ffc1330826574d9d8fff5a644c3390c68:47" I have a spec file: var a = require('hello.js'); describe("a test test", function() { it("humperdink test", function() { expect(a).toEqual('humperdink'); }); //end it }); //end describe hello.js is this: var a

Issue getting Karma 1.1.0 and Angular 2 tests working

时光总嘲笑我的痴心妄想 提交于 2019-12-22 05:26:04
问题 I use Karma 1.1.0. Here is my karma.shim: 'use strict'; // Tun on full stack traces in errors to help debugging Error.stackTraceLimit = Infinity; jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; // // Cancel Karma's synchronous start, // // we will call `__karma__.start()` later, once all the specs are loaded. __karma__.loaded = function() {}; var map = { 'app': 'base/app', 'rxjs': 'base/node_modules/rxjs', '@angular': 'base/node_modules/@angular' }; // packages tells the System loader how to load

Karma and RequireJS: avoid duplication in src and test RequireJS config

荒凉一梦 提交于 2019-12-22 05:06:57
问题 For example, this test-main.js and this main.js has duplicated paths and shims. For large projects, there may be lots of them. I can even use grunt-bower-requirejs plugin to add installed Bower components into main.js, but after that, I have to copy them to test-main.js, either by hand or by program. Is there any convenient way to avoid this duplication, for example, tell RequireJS to include another config file? 回答1: I also hate to duplicate information. I work around that problem by using

Getting Karma, 6to5ify and Istanbul to play ball

两盒软妹~` 提交于 2019-12-22 05:04:19
问题 I have Browserify, 6to5ify and Karma to play nice, successfully running my specs. When I add code coverage however, things go south. I've tried several approaches: Add browserify-istanbul transform to my karma.conf.js. However, this results in it trying to run instrumentation on my spec-files as well it would appear. Run coverage preprocessor on my source files. But because istanbul (even douglasduteil/karma-coverage#next ) doesn't read my 6to5ify browserify transform, this crashes

Error: [$injector:nomod] Module 'ui.bootstrap' is not available! while Karma run in webstorm

北慕城南 提交于 2019-12-22 04:43:12
问题 Hi I'm getting the following error in webstorm while running karma test run Error: [$injector:nomod] Module 'ui.bootstrap', 'ui.unique' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. i looked in the internet and they said to check dependency file ui.bootstrap might be missed like that. but the application works fine and while testing only it shows this error in my karma.conf

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

how to test $window.open using jasmine

萝らか妹 提交于 2019-12-22 04:06:56
问题 This is my function $scope.buildForm = function (majorObjectId, name) { $window.open("/FormBuilder/Index#/" + $scope.currentAppId + "/form/" + majorObjectId + "/" + name); }; This is my jasmine test spec it('should open new window for buildForm and with expected id', function () { scope.majorObjectId = mockObjectId; scope.currentAppId = mockApplicationId; var name = "DepartmentMajor"; scope.buildForm(mockObjectId, name); scope.$digest(); expect(window.open).toHaveBeenCalled(); spyOn(window,