karma-mocha

Uncaught Error: Module name “lib/chai” has not been loaded yet for context: use require([])

倾然丶 夕夏残阳落幕 提交于 2019-12-13 02:46:58
问题 i m using karma-mocha ..my karma.conf file is working with karma-jasmine...but not working with karma-mocha....my karma.conf file:-- module.exports = function(config){ config.set({ basePath : '../app', preprocessors: { '**/*.html':'ng-html2js' }, ngHtml2JsPreprocessor: { prependPrefix: '/' }, files : [ 'node_modules/jquery/**/*.js', 'lib/angular/angular.js', 'lib/angular/angular-*.js', '../test/lib/angular-mocks.js', '../test/lib/sinon-1.15.0.js', '../test/chai/chai.js', 'js/**/*.js', '..

Promises with $q and angular in karma, mocha & chai

南笙酒味 提交于 2019-12-13 02:12:53
问题 So i tried to get the promises to work in my angular app tests, can anyone figure out what im doing wrong here it keeps returning: Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test. I don't know if it's $q. FYI i also tried the it('test', function(done){... done();}) Controller (function() { 'use strict'; angular .module('controller.editor', []) .controller('EditorController', EditorController); function EditorController($scope, $q) { var vm = this;

Run AngularJS resource tests without mocking responses

徘徊边缘 提交于 2019-12-13 01:13:39
问题 I'm using karma, mocha and chai to write tests for the resources in my AngularJS project and everything works great. Today, I'm using $httpBackend to mock every response when the resources are doing http requests. I wonder, however, if I would be able to run the tests without mocking the responses and testing out the real backend integration. Can't seem to find any way to do this. 来源: https://stackoverflow.com/questions/30346214/run-angularjs-resource-tests-without-mocking-responses

why “[web-server]: 404: /absoluteC” when running karma

跟風遠走 提交于 2019-12-11 17:36:27
问题 I found several similar question but none of the suggestions fixed my issue. Basically they are suggesting add some dependency (I am using only native webcomponents so it doesn't appliy to my case) or check the path. I checked carefully and the path is 100% correct. I found a bit strange that the warnning message shows absolute before the real path. BTW, the path is really coorect. Whole code github Karma.conf.js module.exports = function(config) { config.set({ frameworks: ["jasmine"], files:

Cannot find module error when using karma-webpack

北城以北 提交于 2019-12-10 23:27:50
问题 I have the following karma.conf.js file, I also have a test file called example.spec.js that lives inside app/compontents/example/example.spec.js I am trying to import my Example.js file import Example from 'app/components/Example/Example.jsx'; describe('Example Component', function() { }); But I get the following error Error: Cannot find module "app/components/Example/Example.jsx" I have tried many different ideas, such as ./Example.jsx , ./Example , components/Example/Example.jsx but each

webpackJsonp not defined using karma-webpack?

扶醉桌前 提交于 2019-12-10 18:12:21
问题 I am building a boilerplate with webpack and karma with mocha. This is the configuration I am using for karma-webpack. I am new to webpack. var path = require('path'); var webpack = require('webpack'); var entries = { "app": ["./index.js"] }; var root = './'; var testSrc = path.join(root, 'tests/'); var jsSrc = path.join(root, 'src/javascripts/'); var publicPath = path.join(root , 'public/'); var filenamePattern = 'index.js'; var extensions = ['js'].map(function(extension) { return '.' +

How do I run only certain tests in karma?

拈花ヽ惹草 提交于 2019-12-10 14:36:27
问题 I have karma config set up correctly, config file, running in the background, just great. As soon as I change and save a file, it reruns the tests.... all 750 of the unit tests. I want to be able to run just a few. Short of manually hacking the config file or commenting out hundreds of tests across many files, is there any easy way to do it? E.g. when running command line server tests using say mocha, I just use regexp: mocha -g 'only tests that I want' . Makes it much easier to debug and

nock is not intercepting my request

你说的曾经没有我的故事 提交于 2019-12-10 02:54:24
问题 I'm trying to create some basic tests using karma server and nock. It seems like nock is not intercepting my requests at all, does anyone have idea? I can't figure out what is missing. I still getting real data. nock('https://api.github.com/users/' + username).log(console.log) .get('/') .query(true) .reply(400, { statusMessage: 'Bad Request', foo: 'foo' }) http.get('https://api.github.com/users/' + username, function(res) { console.log('res', res) }) I also added this middleware const

Karma and React, have warnings to cause errors

余生颓废 提交于 2019-12-10 02:14:03
问题 I am using Karma with mocha to test my React components. I have some warnings displayed when the PropTypes are not matched. However it would be really interesting to have these warnings to cause an actual error, as to track down the test and fix it. Do you know how this could be achieved? 回答1: You can replace the console.warn method with your own and throw when the message provided matches a certain pattern. let warn = console.warn; console.warn = function(warning) { if (/(Invalid prop|Failed

Error in Unit Test VueJS component with Vuex

。_饼干妹妹 提交于 2019-12-07 03:25:04
问题 Error: undefined is not a constructor (evaluating 'vm.$el.querySelector('h3')') Follow my code and full code here // main.js import Vue from 'vue' import App from './App' import router from './router' import store from './store' import 'babel-polyfill' require('es6-promise').polyfill() Vue.config.productionTip = false /* eslint-disable no-new */ new Vue({ el: '#app', router, store, template: '<App/>', components: { App } }) // Home.vue <template> <div> <h3 class="ui center aligned header"> An