karma-runner

Test module can't resolve module being tested [Angular4, Karma, Jasmine]

我们两清 提交于 2020-01-04 05:27:06
问题 I have a small TypeScript app created as a demo project. It is using Angular 4, Karma, Webpack 2 and Jasmine. The app builds successfully and I can run it in a browser. The tests do not work, when I run karma start in the command line, I see a message like this: ERROR in ./app/welcome/app.welcome.spec.ts Module not found: Error: Can't resolve './app.welcome' in 'D:\ng-ts-demo\app\welcome' @ ./app/welcome/app.welcome.spec.ts 4:20-44 @ ./app .spec.ts @ ./app/test-main.ts The weird thing is, the

DEPRECATION:', 'Setting specFilter directly on Env is deprecated, please use the specFilter option in configure'

梦想的初衷 提交于 2020-01-03 11:28:10
问题 I'm using karma + jasmine in my angular 6 application and I'm receiving the following warining: DEPRECATION:', 'Setting specFilter directly on Env is deprecated, please use the specFilter option in configure' What should I do to make solve this warning? 回答1: I was using the version 1.1.1 of karma-jasmine package. Reading this post, I updated it to version 2.0.1 and the warning disappeared. 来源: https://stackoverflow.com/questions/53724061/deprecation-setting-specfilter-directly-on-env-is

testing an angular checkbox using in jasmin

℡╲_俬逩灬. 提交于 2020-01-03 10:44:54
问题 My situation is as follows: directive scope: { foo:'=' }, template: '<input type="checkbox" ng-model="foo"/>' parent controller $scope.foo = false; jasmine test var cb = iElement.find('input'); $timeout(function() { // using $timeout to ensure $digest() isn't the issue. cb.prop('checked',!cb.prop('checked')) },0); expect(cb.prop('checked')).toBe(true); // passes expect($scope.foo).toBe(true); // doesn't pass My question: why doesn't $scope.foo get updated when I issue the prop('checked') even

Jasmine: How to see the reports in the browser?

前提是你 提交于 2020-01-03 09:47:32
问题 THE SITUATION: I am currently running AngularJs unit tests in the console. I open the folder in the console and i run karma start and check the result of the tests in the console. I would like to see the results in the browser but I cannot see them so far. All i can see is this: THE QUESTION: How can i see the reports of the tests in the browser? The proper plugin should be karma-jasmine-html-reporter right? THE CONFIGURATION: karma.conf.js: frameworks: ['jasmine'], files: [ 'bower_components

Instanbul Keeps Dumping Coverage Report HTML files in wrong directory

别来无恙 提交于 2020-01-03 06:19:27
问题 Here's my config file: module.exports = function(config) { config.set({ basePath: './', autoWatch: true, frameworks: ['jasmine'], files: [ '../public_html/libs/mylib/lib.js', '../public_html/libs/mylib/utility.js', '../public_html/libs/mylib/config/*.js', '../public_html/libs/mylib/enumerations.js', '../public_html/libs/mylib/apiComm.js', '../public_html/libs/mylib/baseObject.js', '../public_html/libs/mylib/book.js', '../public_html/libs/mylib/file.js', '../public_html/libs/mylib/library.js',

Error in karma testing:oc.lazyLoad

不想你离开。 提交于 2020-01-03 03:48:10
问题 I am getting this error in Karma while testing Error: [$injector:modulerr] Failed to instantiate module *** due to: Error: [$injector:modulerr] Failed to instantiate module oc.lazyLoad due to: No module found during bootstrap, unable to init ocLazyLoad This is my angular init: angular.module('*** ', [ 'ui.router', 'ui.bootstrap', 'oc.lazyLoad', 'ngResource', 'pascalprecht.translate', ]) Can you help me to resolve this please 回答1: I've resolved this problem by installing ocLazyLoad another

Karma-webpack+angular TypeError: undefined is not an object (evaluating '$httpBackend.expectPOST'

半腔热情 提交于 2020-01-02 14:36:08
问题 I got the following error PhantomJS 2.1.1 (Linux 0.0.0) leave API service create(): should create a leave FAILED static/app.min.js:4804:54 forEach@static/app.min.js:440:25 loadModules@static/app.min.js:4764:13 createInjector@static/app.min.js:4686:31 WorkFn@node_modules/angular-mocks/angular-mocks.js:3120:60 loaded@http://localhost:9876/context.js:151:17 TypeError: undefined is not an object (evaluating '$httpBackend.expectPOST') in test/leave.service.tests.js (line 65) test/leave.service

How to run Karma with Firefox using Xvfb?

浪子不回头ぞ 提交于 2020-01-02 08:12:23
问题 I want to start Firefox using Xvfb to run Karma in a headless server. Karma needs a launcher plugin to start and stop browsers automatically. I've found a karma-xvfb-chrome-launcher, but no one for Firefox. After installing Xvfb (Ubuntu), I know I can start Firefox using the following command: $ xvfb-run firefox <app-under-test-url> What I don't know is how to make Karma start Firefox this way. Is there a way to provide a custom start/stop browser script to Karma work with? Is possible to do

How to run Karma with Firefox using Xvfb?

烂漫一生 提交于 2020-01-02 08:12:08
问题 I want to start Firefox using Xvfb to run Karma in a headless server. Karma needs a launcher plugin to start and stop browsers automatically. I've found a karma-xvfb-chrome-launcher, but no one for Firefox. After installing Xvfb (Ubuntu), I know I can start Firefox using the following command: $ xvfb-run firefox <app-under-test-url> What I don't know is how to make Karma start Firefox this way. Is there a way to provide a custom start/stop browser script to Karma work with? Is possible to do

Unit testing a directive whose templates are all one with file with script tags

折月煮酒 提交于 2020-01-02 03:59:07
问题 I am having a hard time figuring out how to include my directive's templates (that are all in one file in different script tags) in my Karma unit tests. The error I get: PhantomJS 1.9 (Linux) ERROR SyntaxError: Parse error at /var/www/html/tweak/core/global/views/js/modules/datable/templates.html:1 PhantomJS 1.9 (Linux): Executed 0 of 0 ERROR (0.313 secs / 0 secs) Here are the relevant parts of the code: My directives meat: return { scope : { columns : '=', config : '=' }, templateUrl :