testing

How can I test an Angular 2 ErrorHandler implementation?

断了今生、忘了曾经 提交于 2020-01-23 05:57:34
问题 I have overridden the @angular/core ErrorHandler and I am trying to test it, however I am getting an error. The service works properly but the test fails somewhere. exception-handler.service.ts import { Injectable, ErrorHandler, forwardRef, Inject } from '@angular/core'; import { BkHttp } from './http.service'; @Injectable() export class BkExceptionHandlerService implements ErrorHandler { constructor( private bkHttp: BkHttp) { } handleError(error) { let originalError = this.controlError(error

How can I test an Angular 2 ErrorHandler implementation?

喜夏-厌秋 提交于 2020-01-23 05:56:50
问题 I have overridden the @angular/core ErrorHandler and I am trying to test it, however I am getting an error. The service works properly but the test fails somewhere. exception-handler.service.ts import { Injectable, ErrorHandler, forwardRef, Inject } from '@angular/core'; import { BkHttp } from './http.service'; @Injectable() export class BkExceptionHandlerService implements ErrorHandler { constructor( private bkHttp: BkHttp) { } handleError(error) { let originalError = this.controlError(error

How can I test an Angular 2 ErrorHandler implementation?

拜拜、爱过 提交于 2020-01-23 05:56:19
问题 I have overridden the @angular/core ErrorHandler and I am trying to test it, however I am getting an error. The service works properly but the test fails somewhere. exception-handler.service.ts import { Injectable, ErrorHandler, forwardRef, Inject } from '@angular/core'; import { BkHttp } from './http.service'; @Injectable() export class BkExceptionHandlerService implements ErrorHandler { constructor( private bkHttp: BkHttp) { } handleError(error) { let originalError = this.controlError(error

RSpec: difference between “should == …” and “should eql(…)”

余生长醉 提交于 2020-01-23 05:16:26
问题 In RSpec, what's the difference between using should == ... and should eql(...) ? I noticed that the RSpec documentation always uses eql , but == is less typing and easier to read. What am I missing? 回答1: It's rather simple, really: should == sends the == message to the test subject, should eql sends the eql? message to the test subject. In other words: the two different tests send two completely different messages which invoke two completely different methods and thus do two completely

RSpec: difference between “should == …” and “should eql(…)”

北城余情 提交于 2020-01-23 05:16:15
问题 In RSpec, what's the difference between using should == ... and should eql(...) ? I noticed that the RSpec documentation always uses eql , but == is less typing and easier to read. What am I missing? 回答1: It's rather simple, really: should == sends the == message to the test subject, should eql sends the eql? message to the test subject. In other words: the two different tests send two completely different messages which invoke two completely different methods and thus do two completely

How do I mock an IMAP server in Python, despite extreme laziness?

戏子无情 提交于 2020-01-23 04:51:07
问题 I'm curious to know if there is an easy way to mock an IMAP server (a la the imaplib module) in Python, without doing a lot of work. Is there a pre-existing solution? Ideally I could connect to the existing IMAP server, do a dump, and have the mock server run off the real mailbox/email structure. Some background into the laziness: I have a nasty feeling that this small script I'm writing will grow over time and would like to create a proper testing environment, but given that it might not

how to test prefetch/prerender

放肆的年华 提交于 2020-01-23 04:48:09
问题 I have started to load a few key resources and pages using the prefetch/prerender system. Is there a way to ensure that the resources in question are actually being preloaded? 回答1: Google recommends using the Page Visibility API to test if a page is being prerendered. I'm not sure how well it works cross-browser (but what does in HTML5). 回答2: You can also use prerender-test.appspot.com to test that your site works correctly under prerendering. Further, from within Chrome, you can go to chrome

Prevent zombie.js from loading only external resources

喜欢而已 提交于 2020-01-22 22:56:08
问题 I am using zombie.js to load a page from a local express server during a test. Unfortunately, there is a script element which calls out to Google Analytics. I would like to block this external script (gracefully) without preventing other (local) scripts from loading, if possible. I know that { runScripts : false } is available with calls to browser.visit() . However, that refuses to load any and all scripts on the page, not just those living on other hosts. Is this possible? 回答1: You should

How Mocha knows which file to load first in the test suite

烈酒焚心 提交于 2020-01-22 19:53:11
问题 I'm trying to learn the A Test Driven Approach with MongodB. The folder structure A user.js to test in the src folder const mongoose = require('mongoose'); mongoose.Promise = require('bluebird'); const Schema = mongoose.Schema; const UserSchema = new Schema ({ name: String }); const User = mongoose.model('user', UserSchema); module.exports = User; Content of test_helper.js const mongoose = require('mongoose');; mongoose.connect('mongodb://localhost/users_test'); mongoose.connection .once(

Django Test Database looks empty while test is runnin

巧了我就是萌 提交于 2020-01-22 18:25:21
问题 I have a Django project that uses local PostgreSQL server. I'm using a debugger to debug some weird bugs that I have. While the debugger is stopped on one of the tests, I tried to look at the test database. I see this new database (test_project1) and all the schemes are defined as they should be. But all tables are empty. I know that the tables are not empty: - I used fixture and some tests already ran and returned data. - A post test created new user returned 201 status code. And yet, I see