随笔分类 -  Unit Testing

摘要:While not all of accessibility testing of a web application can be automated, much of it can be and quite easily using axe-core and jest-axe. Let’s se 阅读全文
posted @ 2020-04-30 19:09 Zhentiw 阅读(245) 评论(0) 推荐(0) 编辑
摘要:You can use 'rerender' for a component when its props changed. Then if you wnat to check the alert message has gone when we rerender, you need to use 阅读全文
posted @ 2020-04-30 18:57 Zhentiw 阅读(195) 评论(0) 推荐(0) 编辑
摘要:The User Event module is part of the Testing Library family of tools and lets you fire events on DOM nodes that more closely resemble the way your use 阅读全文
posted @ 2020-04-30 18:45 Zhentiw 阅读(149) 评论(0) 推荐(0) 编辑
摘要:The fireEvent utility in React Testing Library supports all the events that you regularly use in the web (change, click, etc.). Let’s see how we can t 阅读全文
posted @ 2020-04-30 18:00 Zhentiw 阅读(396) 评论(1) 推荐(0) 编辑
摘要:While you’re writing your tests it can be helpful to see what the DOM looks like. You can do this with React Testing Library’s debug function which wi 阅读全文
posted @ 2020-04-30 17:50 Zhentiw 阅读(183) 评论(0) 推荐(0) 编辑
摘要:Component: import React from 'react' function FavoriteNumber({ min = 1, max = 9 }) { const [number, setNumber] = React.useState(0) const [numberEntere 阅读全文
posted @ 2020-04-30 17:47 Zhentiw 阅读(177) 评论(0) 推荐(0) 编辑
摘要:We can use 'jest.spyOn', similr to 'spyOn' in Jasmine. jest.spyOn(utils, 'getWinner') We get 'getWinner' as a method. Jest has mockImplementation: // 阅读全文
posted @ 2020-04-30 15:01 Zhentiw 阅读(212) 评论(0) 推荐(0) 编辑
摘要:Epic: import { ofType } from 'redux-observable' import { of, concat, merge, fromEvent, race, forkJoin } from 'rxjs' const buildAPI = (apiBase, perPage 阅读全文
posted @ 2020-04-30 01:57 Zhentiw 阅读(402) 评论(0) 推荐(0) 编辑
摘要:Component to be tested: <ng-template #defaultPlaceholder> Loading... </ng-template> <div class="loading-container" *ngIf="loading$ | async"> <ng-conta 阅读全文
posted @ 2020-03-25 19:29 Zhentiw 阅读(3381) 评论(0) 推荐(0) 编辑
摘要:Component: <div class="loading-placeholder" [ngClass]="extraClass"> &nbsp; <ng-container *ngIf="loadingService.config.showContent"> <ng-content></ng-c 阅读全文
posted @ 2020-03-24 22:15 Zhentiw 阅读(263) 评论(0) 推荐(0) 编辑
摘要:Component: import { Component, OnInit } from "@angular/core"; import { TwainService } from "../twain.service"; import { Observable, of } from "rxjs"; 阅读全文
posted @ 2020-03-03 17:55 Zhentiw 阅读(478) 评论(0) 推荐(0) 编辑
摘要:The component we test against: import {Component, OnInit} from '@angular/core'; import {Course} from "../model/course"; import {Observable} from "rxjs 阅读全文
posted @ 2020-02-25 19:55 Zhentiw 阅读(343) 评论(0) 推荐(0) 编辑
摘要:In this post, we are going to see how to use 'fakeAsync' to test async code in Angular Context. fakeAsync using Zoom.js underhook, it detects all the 阅读全文
posted @ 2020-02-20 17:59 Zhentiw 阅读(285) 评论(0) 推荐(0) 编辑
摘要:The smart component we want to test: import {Component, OnInit} from '@angular/core'; import {Course} from "../model/course"; import {Observable} from 阅读全文
posted @ 2020-02-19 17:17 Zhentiw 阅读(967) 评论(0) 推荐(0) 编辑
摘要:In Angular version 8, TestBed.get was deprecated. In Angular version 9, we see why: TestBed.inject<T> is introduced as a type-safe replacement. There 阅读全文
posted @ 2020-02-17 16:48 Zhentiw 阅读(142) 评论(0) 推荐(0) 编辑
摘要:Setting up a Presentational Component: import {Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation} from '@angular/core'; import {Course 阅读全文
posted @ 2020-02-14 17:19 Zhentiw 阅读(512) 评论(0) 推荐(0) 编辑
摘要:How to test a service The service we want to test against: import {Injectable} from '@angular/core'; import {LoggerService} from './logger.service'; @ 阅读全文
posted @ 2020-02-12 16:50 Zhentiw 阅读(463) 评论(0) 推荐(0) 编辑
摘要:it ('should add two numbers', () => { const logger = jasmine.createSpyObj('LoggerService', ['log']) // logger.log.and.returnValue(); const calculator 阅读全文
posted @ 2020-02-10 02:52 Zhentiw 阅读(183) 评论(0) 推荐(0) 编辑
摘要:beforeEach(() => { contextStub = { debug: false, engine: jasmine.createSpyObj('engine', [ 'createCollection', 'createContext', 'createSchematic', 'createSourceFromUrl', 'transformOptions', 'executePos 阅读全文
posted @ 2019-12-12 20:59 Zhentiw 阅读(517) 评论(0) 推荐(0) 编辑
摘要:It is recommened to write unit testing with Mockito in Spring framework, because it is much faster with Spring framework test. But in case you can doi 阅读全文
posted @ 2019-04-24 15:43 Zhentiw 阅读(211) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示