karma-jasmine

How to debug HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR { “isTrusted”: true } in Angular 6 unit test?

狂风中的少年 提交于 2019-12-11 12:35:32
问题 When I run my test suite, I get an error in a totally different unit test than the one I've been working in. What am I doing wrong? HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR { "isTrusted": true } It is then followed by some build steps and the following error during test execution: HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR An error was thrown in afterAll [object ErrorEvent] thrown If I comment out certain tests, say in class A, another test fails in Component B. If I comment those out, another

Grails asset pipeline exclude not working

岁酱吖の 提交于 2019-12-11 12:31:10
问题 I have a project on Grails and angular.js. Also I have tests which runs on karma+jasmin. My directory structure is: grails-app assets images javascripts locales stylesheets test On production all my assets are building on bamboo. The problem is that I want to exclude from compiling test folder with all that inside of it and can't do that. In my Config.groovy I've added grails.assets.excludes = ["test/**/(*.js|*.json)"] Also I've tried different patterns for exclude and they all not working.

AngularJS & Karma-Jasmine - How to ignore templateUrl to avoid “Unexpected request: GET …/.html”

徘徊边缘 提交于 2019-12-11 12:28:58
问题 I'm working on an AngularJS app using ES6, so I will have as little work as possible when migrating to AngularJS 2.0 But I found out that it's a bit more complicated to do unit tests. So what I want to do is to test directive's "controller" (loginSidebarCtrl) Here is my code: (LoginSidebar.js) class LoginSidebar { constructor(loginSidebarService) { this.loginSidebarService = loginSidebarService; } /* ... SOME METHODS ... */ } LoginSidebar.$inject = ['loginSidebarService']; export default

Jasmine doesn't inject services

别说谁变了你拦得住时间么 提交于 2019-12-11 12:14:20
问题 Premise: my app works perfectly, but anyway I decided to imoplement units tests. My test, that check if a service given object is defined or not fails. here is my service code: //app/components/lib/search.js angular.module("search", ["lazyLoad", "httpInterceptor"]) .service("SearchObject", ['$rootScope', '$location', 'Globals', function ($rootScope, $location, Globals) { 'use strict'; var obj, SearchObjectPrototype = {}; SearchObjectPrototype.clone = function (source) { var prop; for (prop in

Karma not running simple typescript test (using SystemJS + Jasmine)

偶尔善良 提交于 2019-12-11 09:05:35
问题 I have been struggling with running a very simple typescript unit test that returns "hello" using Karma, Jasmine, SystemJs. Grabbed the project from Aurelia Typescript ASP.NET Core skeleton here but since then I've got no luck in running the unit tests even those included in the skeleton much less with e2e tests. Since it is from the aurelia skeleton, I am using 'gulp test' to run the unit test. Thanks for your help!! so when running I am getting : 665:DEBUG [config]: autoWatch set to false,

Karma Webpack Jasmine Unit Testing not working

牧云@^-^@ 提交于 2019-12-11 08:51:50
问题 I am trying to setup testing with Karma, Jasmine, Webpack in AngularJS. My webpack is working fine and I can run my website using npm start A simple test works fine but the moment I try to add my app.js everything goes downhill. I have tried many many many searches and many solutions. Please dont think, I am writing this question the moment I hit a deadend. I have spent all day today just googling and find possible solutions. There is my karma.conf.js file // Karma configuration // Generated

AngualrJS with Karma - how do I write a unit test for a factory?

女生的网名这么多〃 提交于 2019-12-11 08:14:40
问题 I am writing a simple AngularJS 1.x web app. I have a module: main.js: var app = angular.module('app', []); factory.js app.factory('DataFactory', function(){ var DataService = {}; DataService.something = function() { return 5; }; return DataService; }); controller.js app.controller('DataController', function ($scope, DataFactory) { $scope.searchText = null; $scope.results = DataFactory.something(); }); index.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <script src=

Angular 2.0.0 - Mocking Components

假装没事ソ 提交于 2019-12-11 08:05:43
问题 How do you mock a component in Angular 2.0.0 Final Release? I have a problem in mocking a component that has a variable that I use for logic in another component. Specifically, I want to mock a PrimeNG Datatable selection. Sample code below. table.component.html <p-dataTable #table [value]="myDatasource" [(selection)]="mySelections" ... > table.component.ts @Component({ selector: 'my-table', templateUrl: './table.component.html' }) export class TableComponent{ @ViewChild('table') datatable;

Unexpected value 'undefined' imported by the module 'DynamicTestModule' in jasmine-karma

回眸只為那壹抹淺笑 提交于 2019-12-11 08:05:21
问题 I am doing unit testing using jasmine-karma. configuration - "@types/jasmine": "~2.8.6", "@types/jasminewd2": "~2.0.3", "@types/jquery": "^3.3.22", "@types/node": "~8.9.4", "codelyzer": "~4.2.1", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~1.7.1", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~1.4.2", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", I am getting the same error for all the test cases. Error: Unexpected

Implement unit testing with jasmine/karma by mocking Http Post - Angular 5

北城以北 提交于 2019-12-11 07:49:01
问题 I am completely new to unit testing and I am implementing unit testing using jasmine/karma for the first time. I am facing few issues in understanding how I should implement testing by mocking for Http Post. I have gone through few solutions such as : solution1 and solution2 But still I have faced few issues in understanding them and have also faced few errors. By following solution2 I have tried to implement as follows: http.service.ts update(id,password,url){ let content = { "username": id,