karma-jasmine

How to load an Aurelia plugin in Karma

南笙酒味 提交于 2019-12-10 17:04:07
问题 I've this ViewModel which is a login confirmation page viewmodel: src/pages/confirm.ts import { autoinject } from 'aurelia-framework'; import { Router, NavigationInstruction } from 'aurelia-router'; import { ValidationControllerFactory, ValidationController, ValidationRules } from 'aurelia-validation'; import { LoginService } from '../services/login.service'; import { Settings } from '../config/settings'; import { State } from '../services/state'; import { Helpers } from '../services/helpers'

How to setup NativeScript Angular with Karma, karma-typescript, Jasmine, Mocha, Chai

吃可爱长大的小学妹 提交于 2019-12-10 13:46:47
问题 I'm trying to configure karma.config.js to run with NativeScript Angular project following the official doc: https://docs.nativescript.org/angular/tooling/testing The problem is the tests always failed and always running node_modules/ and platforms/ too but I mentioned them in excludeFiles property. I created a github repo to reproduce it I'm using a separated branches to reproduce it with jasmine and mocha https://github.com/francisrod01/native-script-angular2-karma-demo Scenario 1: karma

Uncaught ReferenceError: require is not defined on karma start karma.conf.js

丶灬走出姿态 提交于 2019-12-10 13:27:38
问题 Using Karma and Jasmine for unit testing on the angular front-end of a rails app. It appears I've done everything known to man to get through this error and I'm left with a million dependencies in my package.json. Here is my Karma.conf.js: module.exports = function(config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '', // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter // list of files /

Karma not running tests that have “import” statements in karma-webpack

我的梦境 提交于 2019-12-10 13:21:46
问题 I have some test files with tests I'd like to run against my app. I am attempting to use karma , karma-webpack , karma-babel-preprocessor , karma-chrome-launcher , and jasmine in my testing. My app depends on many things, including backbone , marionette , etc. My app is built using webpack , and I am attempting to use webpack to bundle my files together for testing. (I initially wanted to see if I could skip this step, i.e. simply import a file to be tested, but it seems this is impossible.)

TeamCity: PhantomJS have not captured in 60000 ms, killing

蹲街弑〆低调 提交于 2019-12-10 13:18:56
问题 I'm encountering an issue when running tests in my CI environment. The configuration works fine on MacOS 10.11.6 (El Capitan), with Node v6.0.0 / npm 3.8.6, but on a TeamCity 9.1.6 agent running Windows with Node v4.2.2 / npm 2.14.7, it fails miserably with an error of PhantomJS have not captured in 60000 ms . Here's an example stacktrace on TeamCity: [08:58:40][exec] 02 11 2016 08:58:41.095:DEBUG [config]: autoWatch set to false, because of singleRun [08:58:40][exec] 02 11 2016 08:58:41.102

Angular: Unit Testing Routing : Expected '' to be '/route'

☆樱花仙子☆ 提交于 2019-12-10 09:36:41
问题 Am working on unit testing for my routing under my Angular app , My routes are delacred in a specific module which is imported under the app.module.ts , here is my routing module: app-routing.module.ts import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { LoginComponent } from './login/login.component'; import { WelcomeComponent } from './welcome/welcome.component'; import { CustomersListComponent } from './customer/customers-list/customers

How to test the config function of an Angular module?

旧街凉风 提交于 2019-12-10 02:56:54
问题 I'm defining some setup code in the config function of an Angular module that I want to unit test. It is unclear to me how I should do this. Below is a simplified testcase that shows how I'm getting stuck: 'use strict'; angular.module('myModule', []).config(['$http', '$log', function($http, $log) { $http.get('/api/getkey').then(function success(response) { $log.log(response.data); }); }]); describe('myModule', function() { it('logs a key obtained from XHR', inject(function($httpBackend) {

Karma error - Chrome have not captured in 60000 ms, killing

谁都会走 提交于 2019-12-09 16:24:22
问题 DEBUG LOG: E:\Projects\abb\Projects\WebApp\abb.web>karma start DEBUG [plugin]: Loading karma-* from E:\Projects\abb\Projects\WebApp\abb .web\node_modules DEBUG [plugin]: Loading plugin E:\Projects\abb\Projects\WebApp\abb.web\n ode_modules/karma-chrome-launcher. DEBUG [plugin]: Loading plugin E:\Projects\abb\Projects\WebApp\abb.web\n ode_modules/karma-jasmine. INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/ INFO [launcher]: Starting browser Chrome DEBUG [temp-dir]:

How to unit test the checkbox in Angular2

回眸只為那壹抹淺笑 提交于 2019-12-09 16:14:16
问题 I have a sample code for checkbox written with Angular2. <div class="col-sm-7 align-left" *ngIf="Some-Condtion"> <input type="checkbox" id="mob_Q1" value="Q1" /> <label for="mob_Q1">Express</label> </div> I want to unit test the above checkbox. Like I want to recognize the checkbox and test whether it is check-able. How do I unit test this with Karma Jasmine? 回答1: Component, e.g. CheckboxComponent, contains input element. Unit test should looks like: import {ComponentFixture, TestBed} from '

How do I mock $window injected manually in provider private function?

廉价感情. 提交于 2019-12-09 13:30:03
问题 I have the following provider: angular.module('MyApp').provider('MyDevice', function () { var ngInjector = angular.injector(['ng']), $window = ngInjector.get('$window'); function isMobileDevice () { return (/iPhone|iPod|iPad|Silk|Android|BlackBerry|Opera Mini|IEMobile/) .test($window.navigator.userAgent || $window.navigator.vendor || $window.opera); } this.$get = function () { return { isDesktop: function () { return !isMobileDevice(); }, isMobile: function () { return isMobileDevice(); } };