karma

Test Coverage React, Istanbul -_registerComponent(…): Target container is not a DOM element

匿名 (未验证) 提交于 2019-12-03 01:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am writing an app with react / redux / webpack. I am building out my testing with karma, mocha and want to use istanbul for test coverage. In an attempt to get coverage to work with karma-coverage I have set up the following karma.config.js var argv = require ( 'yargs' ). argv ; var path = require ( 'path' ); var webpack = require ( 'webpack' ); const PATHS = { test : path . join ( __dirname , 'test' ), app : path . join ( __dirname , 'app' ), } module . exports = function ( config ) { config . set ({ // only use PhantomJS for

Karma cannot load imported files

匿名 (未验证) 提交于 2019-12-03 00:59:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been struggling for days now with the fact I cannot run any real test with Karma. I can run tests which do not require imports (like basic sanity tests) but as soon I have to import something from my app I get the error: system.src.js:1085 GET http://localhost:9876/base/dist/components/test.service 404 (Not Found)fetchTextFromURL @ system.src.js:1085(anonymous function) @ system.src.js:1646ZoneAwarePromise @ angular2-polyfills.js:589(anonymous function) @ system.src.js:1645(anonymous function) @ system.src.js:2667(anonymous function) @

How to load an Aurelia plugin in Karma

匿名 (未验证) 提交于 2019-12-03 00:56:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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'; @autoinject export class Confirm { userName:

Angular2 RC1 Karma Error - unable to find @angular/core/testing

匿名 (未验证) 提交于 2019-12-03 00:53:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to setup Angular2 (RC1 version) project with Karma. I was able to do this setup for ng2 beta.17, but for RC1 I am getting the following error: Error: Error: XHR error (404 Not Found) loading http://localhost:9876/@angular/core/testing at XMLHttpRequest.wrapFn [as _onreadystatechange] ( http://localhost:9876/base/node_modules/zone.js/dist/zone.js?11128be53f306ea156f04e90b0fb7f23fc2104a5:748:30 ) at ZoneDelegate.invokeTask ( http://localhost:9876/base/node_modules/ zone.js/dist/zone.js?11128be53f306ea156f04e90b0fb7f23fc2104a5:341

error in unit test vue.js karma : undefined is not a constructor ()

匿名 (未验证) 提交于 2019-12-03 00:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is my first unit test and I'm getting an error message that couldn't find why I get it in the forums so far. This is my unit test: import LoginPage from 'src/pages/Login' describe('Login.vue', () => { it('mounted is a fuction', () => { expect(typeof LoginPage.mounted).toBe('function') }) }) And this is the login page: <template> <div class=""> <p v-if="$route.query.redirect"> You need to login first. </p> <form class="column is-one-third is-offset-one-third" @submit.prevent="login"> <div class="control"> <input type="email" placeholder=

TeamCity: PhantomJS have not captured in 60000 ms, killing

匿名 (未验证) 提交于 2019-12-03 00:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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:DEBUG [plugin]: Loading plugin karma-jasmine. [08

error TS2300: Duplicate identifier &#039;PropertyKey&#039; in node_modules/@types/core-js/index.d.ts

匿名 (未验证) 提交于 2019-12-03 00:48:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have these errors in node_modules/@types/core-js/index.d.ts in Visual Studio Code IDE: When I run npm start to serve the app, I get: node_modules/@types/core-js/index.d.ts(21,14): error TS2300: Duplicate identifier 'PropertyKey'. node_modules/@types/core-js/index.d.ts(85,5): error TS2687: All declarations of 'name' must have identical modifiers. node_modules/@types/core-js/index.d.ts(145,5): error TS2403: Subsequent variable declarations must have the same type. Variable '[Symbol.unscopables]' must be of type '{ copyWithin: boolean;

搭建 vue2 单元测试环境(karma+mocha+webpack3)

匿名 (未验证) 提交于 2019-12-03 00:18:01
从网上找了很多例子关于单元测试,都是如何新建项目的时候的添加单元测试,用vue-cli中怎么添加,但是我的项目已经生成了,不能再一次重新初始化,这时如何添加单元测试,这里面遇到了好多坑,写在这里记录一下心得。 vue init webpack vuetest npm i -D karma karma -webpack phantomjs -prebuilt karma -phantomjs -launcher karma -phantomjs -shim karma -chrome -launcher karma -sourcemap -loader mocha karma -mocha sinon chai sinon -chai karma -sinon -chai karma -spec -reporter karma -coverage istanbul -instrumenter -loader "unit" : "karma start test/unit/karma.conf.js --single-run" , const srcContext = require .context( '../../src' , true , /^\.\/(?!main(\.js)?$)/ ) 改为: const srcContext = require .context( '../

Angular单元测试与E2E测试

匿名 (未验证) 提交于 2019-12-02 23:03:14
本文介绍了Angular单元测试和E2E测试的配置与测试方法。示例APP使用Angular 7 CLI创建,已配置好基础测试环境,生成了测试样例代码。默认,Angular单元测试使用Jasmine测试框架和Karma测试运行器,E2E测试使用Jasmine测试框架和Protractor端到端测试框架。 配置单元测试 Jasmine是一个用于测试JavaScript的行为驱动开发框架,不依赖于任何其他JavaScript框架。 Karma是测试运行器,为开发人员提供了高效、真实的测试环境,支持多种浏览器,易于调试。 配置文件 单元测试配置文件test.ts和karma.conf.js: test.ts import 'zone.js/dist/zone-testing'; import { getTestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; declare const require: any; // First, initialize the Angular testing environment.

webpack4.0各个击破(9)—— karma篇

坚强是说给别人听的谎言 提交于 2019-12-02 14:01:22
Webpack4.0中级教程 webpack 作为前端最火的构建工具,是前端自动化工具链 最重要的部分 ,使用门槛较高。本系列是笔者自己的学习记录,比较基础,希望通过 问题 + 解决方式 的模式,以前端构建中遇到的具体需求为出发点,学习 webpack 工具中相应的处理办法。(本篇中的参数配置及使用方式均基于 webpack4.0版本 ) 一. webpack与自动化测试 webpack 对应的关键词是模块化,它的主要任务就是打包和管理模块,所以首先需要明确的概念就是 webpack 之所以关联自动化测试,是因为 它能够为测试脚本提供模块管理的能力 ,本质上来讲,是将 webpack 的打包功能嵌入了自动化测试框架,而不是将自动化测试框架作为插件集成进了 webpack ,理解这个区别是非常关键的。 对于 Karma + Mocha + Chai 及其他自动化测试相关工具的话题将在 《大前端的自动化工厂》 系列博文中讲述,本篇主要介绍 karma-webpack 连接件,它从工具实现层面上将自动化测试与自动化构建联系在了一起。 二. karma-webpack 插件地址: https://github.com/webpack-contrib/karma-webpack 2.1 自动化单元测试库简介 先对基本的单元测试工具做一个简要说明: Karma 测试框架