karma-runner

How to deal with thrown errors in async code with Jasmine?

本小妞迷上赌 提交于 2019-12-25 14:25:10
问题 The following test causes Jasmine (2.3.4, run in browser via Karma) to crash and not run any subsequent tests it('should report as failure and continue testing', function (done) { setTimeout(function () { throw new SyntaxError('some error'); done(); }, 1000); }); How can I have this test correctly report itself as a failure and carry on with subsequent tests? 回答1: Mocking the clock will give you the expected result. Mocking the clock in general is a best practice for testing timeouts.

Unit test of $cacheFactory removeAll() in service failing in Angular 1.2.0 but working in 1.0.7

荒凉一梦 提交于 2019-12-25 09:31:35
问题 I have a unit test for an Angular service in which I test that a cache $cacheFactory is cleared after a call has been made for a save() method that does an http post to the backend. In 1.0.7 this test passed in Karma and Jasmine Specrunner.html, but after migrating to Angular 1.2.0 it fails. I have not changed any code in the service or in the spec file. The cache is cleared in production when I check it manually. Any ideas? EDIT: Plunk of the error in action: http://plnkr.co/edit/1INhdM The

Is there a way to use fs sync functions with browserify?

我怕爱的太早我们不能终老 提交于 2019-12-25 09:11:59
问题 I already tried the brfs transformation, but I got the following error message: 08 03 2016 16:50:14.894:ERROR [framework.browserify]: bundle error 08 03 2016 16:50:14.894:ERROR [framework.browserify]: Error: tried to statically call { readFile: [Function: readFile], readFileSync: [Function: readFileSync], readdir: [Function: readdir], readdirSync: [Function: readdirSync] } as a function while parsing file ... PhantomJS 1.9.8 (Windows 7 0.0.0) ERROR You need to include some adapter that

Trouble installing Karma via npm

烂漫一生 提交于 2019-12-25 06:45:27
问题 I'm having trouble installing Karma via npm. My Mac: OS X 10.9.2 (Darwin 13.1.0) My version of node is: v0.10.26 My version of npm is: v1.4.3 sudo npm install -g karma npm http GET https://registry.npmjs.org/karma npm http 304 https://registry.npmjs.org/karma npm http GET https://registry.npmjs.org/di npm http GET https://registry.npmjs.org/socket.io npm http GET https://registry.npmjs.org/glob npm http GET https://registry.npmjs.org/chokidar npm http GET https://registry.npmjs.org/minimatch

karma configuration to disable headless chrome and use only terminal

徘徊边缘 提交于 2019-12-25 01:39:27
问题 I am trying to run Angular unit test. I want to configure karma.config file not to open headless chrome. Simply I want to see output in terminal alone. I tried by commenting below code lines in karma.config .... reporters: ['progress', 'kjhtml'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['Chrome'], singleRun: false reporters: ['progress', 'kjhtml'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['Chrome'], singleRun:

Testacular error: Cannot start chrome [closed]

徘徊边缘 提交于 2019-12-25 01:35:49
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I am going through AngularJS tutorials, and I am stuck on the tutorial for running Testacular tests. I get the following error: Starting Testacular Server (http://vojtajina.github.com/testacular) ------------------------------------------------------------------- info: Testacular server started at http:/

Angular 6 receive input from another component for Karma unit test

雨燕双飞 提交于 2019-12-24 19:11:18
问题 So I'm trying to write Karma tests for a variety of components, and many of them receive input from a parent component. To try to illustrate how tests work, I've created a sample group of 5 different files as a tutorial of sorts: "random.test.component.child.html", "random.test.component.child.ts", "random.test.component.html", "random.test.component.ts", and "random.test.file.spec.ts". I want to receive input from one component and set the value to the variable of the other ([variable]=

Angular6: How can I generate a default angular.json file from command line [duplicate]

不想你离开。 提交于 2019-12-24 19:08:14
问题 This question already has answers here : How to generate .angular-cli.json file in Angular Cli? (9 answers) Closed last year . I create a new module using angular 6, that will serve as a package to use in another project. Now, I'm trying to configure the karma and jasmine so I could create unit tests on it. The problem is that I found out that the project does not have any angular.json file. It is possible to generate a default angular.json file from the command line? 回答1: Your best bet is to

angular-mock testing in Karma+Mocha can't find module

泪湿孤枕 提交于 2019-12-24 16:07:48
问题 I'm learning AJS unit testing, with RequireJS, Karma, Mocha, Chai and angular-mocks. I've had some luck with the first four, but need to get into "real" testing and can't get angular-mocks to work. There's a lot going on, so I'll be as succinct as possible. test/karma.conf.js module.exports = function (config) { config.set({ // requirejs may need to be listed before other modules (see https://github.com/princed/karma-chai-plugins#limited-requirejs-support) frameworks: ["requirejs", "mocha",

Including libraries fails - what is document root?

只愿长相守 提交于 2019-12-24 16:00:23
问题 I have a file ( src/inc.js ) that loads certain files into my browser using jquery's ajax: $.ajax({url: 'somefile.js', async: false, dataType: 'script', error: function(qXHR, textStatus, errorThrown) { console.log( '[' + textStatus + '] ' + errorThrown + ' with: ' + this.url ); } }); and this file gets included via browserification into my browser (phantomjs). Gruntfile.js : browserify: { libs: { src: ['src/*.js'], dest: 'test/libs.js' } } and handed to karma (in Gruntfile.js ): karma: {