karma-runner

Expect not toThrow function with arguments - Jasmine

此生再无相见时 提交于 2020-01-10 12:12:29
问题 I have function that gets 3 arguments. I want to check that this function not throwing an error. I did something like this: expect(myFunc).not.toThrow(); The problem is myFunc need to get arguments. How can I send the arguments? P.S I tried to pass it argument but I got error that myFunc(arg1, arg2, arg3) is not a function. 回答1: toThrow matcher requires function to be passed as argument to expect so you can simply wrap your function call in anonymous function: expect(function() { myFunc(arg1,

Expect not toThrow function with arguments - Jasmine

烂漫一生 提交于 2020-01-10 12:11:22
问题 I have function that gets 3 arguments. I want to check that this function not throwing an error. I did something like this: expect(myFunc).not.toThrow(); The problem is myFunc need to get arguments. How can I send the arguments? P.S I tried to pass it argument but I got error that myFunc(arg1, arg2, arg3) is not a function. 回答1: toThrow matcher requires function to be passed as argument to expect so you can simply wrap your function call in anonymous function: expect(function() { myFunc(arg1,

angular cli exclude files/directory for `ng test --code-coverage`

跟風遠走 提交于 2020-01-09 19:47:08
问题 I am running the following command to unit test and generate code code coverage report. ng test --code-coverage It is working fine and writing code coverage report in coverage folder. In this I got all files and directory coverage report But I want to exclude specific files/directory let say src/app/quote/services/generated . How to do that? 回答1: Updated September 2019 On angular cli 6, angular-cli.json has been renamed to angular.json which contains the configuration. In angular.json ,

Karma e2e testing: how to know when the DOM is ready?

五迷三道 提交于 2020-01-06 07:17:07
问题 I'm writing some e2e tests and up until now I have been using the sleep(x) function to wait for ajax calls. This is not very efficient as I must estimate the value to wait for testing and if I set too big a value then my tests are taking much more time then needed. Is there a way to sleep for an ajax call duration? or at least when redirecting to a different page a way to sleep for the time the DOM is loaded? 回答1: If you do e2e testing with angular scenario runner and karma you do not need to

Error using karma-browserify with browserify-shim

一世执手 提交于 2020-01-06 03:55:05
问题 I'm trying to use karma-browserify together with browserify-shim with no success. Here is a repo to reproduce the error: https://github.com/pelizza/karma-browserify-shim PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR TypeError: undefined is not an object (evaluating 'module.exports = ex') at /var/folders/_0/ql88mbyd6v34qsmysr5kf4780000gn/T/e0c5e5ebe3f49930de3d988c7196737f.browserify:40308 <- bower_components/jquery/dist/jquery.js:9837:0 Everything works fine when bundling with browserify, by it seems

node-gyp rebuild 2 error when installing Karma

三世轮回 提交于 2020-01-06 02:18:11
问题 I am trying to install Karma onto OSX v10.9.3. I open up the terminal and enter npm install -g karma . When I do this, I get the following output: mc-s089979% npm install -g karma > fsevents@0.2.0 install /usr/local/lib/node_modules/karma/node_modules/chokidar/node_modules/fsevents > node-gyp rebuild CXX(target) Release/obj.target/fse/fsevents.o SOLINK_MODULE(target) Release/fse.node SOLINK_MODULE(target) Release/fse.node: Finished > ws@0.4.31 install /usr/local/lib/node_modules/karma/node

Karma unit test cross domain resource AngularJS

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-06 01:22:46
问题 I use karma as my angular project test running framework, my angular have server service need to access another web url to get data like http://localhost:8081/common/countries get all information about country. my problem is my karma start at localhost:9876 and it need to get data from http://localhost:8081/common/countries this cause cross domain problem by the browse same-origin policy. so I get below error in my console: Error: Unexpected request: GET http://localhost:8081/common/countries

karma-webpack : Module name has not been loaded yet for context : use require([])

怎甘沉沦 提交于 2020-01-05 04:16:06
问题 I'm new to Jasmine/Karma unit testing for JavaScript applications. I'm trying to implement it in my current project which is using Angular 1.4.12 and Webpack 1.13.1 for bundling. My folder structure is as follows: The index.js file inside 'core' is trying to require various other modules which are required for Webpack bundling. The file looks like this: require('../../bower_components/font-awesome/css/font-awesome.min.css'); require('../../bower_components/bootstrap/dist/css/bootstrap.min.css

karma-ng-html2js-preprocessor not creating modules

安稳与你 提交于 2020-01-04 06:22:06
问题 Attempting to use the karma-ng-html2js-preprocessor. Karma has been finding all of my other stuff (javascript) fine, but when it comes to this html preprocessor it can't seem to find and generate a module from it. Check out my options object below. As you can see, I've added a pattern to the files attribute and I'm using the generic name 'foo' for the module. In the test, karma throws an error whenever I try to call module('foo'); I really want to be able to use this so I don't have to

How to configure Angular2 Quickstart to run phantomjs?

偶尔善良 提交于 2020-01-04 06:08:29
问题 I am trying to figure out how to run the tests of Angular2 Quickstart with phantomjs. I thought these steps were enough to configure Karma: 1. Clone the repository $ git clone https://github.com/angular/quickstart.git $ cd quickstart 2. Install phantomjs and phantomjs launcher $ npm install --save-dev phantomjs $ npm install --save-dev karma-phantomjs-launcher 3. Change karma.conf.js // First change require('karma-chrome-launcher') => require('karma-phantomjs-launcher') // Second change