Laur's blog
Sign in Subscribe

mock

A collection of 2 posts
Poor Man's Mocks in TypeScript
anonymous

Poor Man's Mocks in TypeScript

Today I went against my better judgement of usign a mock framework and decided to create my own mocks to allow coverage testing for an IPC-calling code. My reference code I wanted to test is: export class ScanTriggerEvent { name: string = 'scan' constructor(private pathService: PathsService) {} /** * Send a scan
Mar 7, 2017 1 min read
Mock an Observable Interface
interface

Mock an Observable Interface

TL;DR: Use a doAnswer() with a new Answer<Observable<Type>>() if you have to mock observables. Today I wrote my first test where I had to mock an observable interface: public interface UserDatabase { Observable<User> readUser(String username); } where the User model is:
Aug 1, 2016 1 min read
Page 1 of 1
Laur's blog © 2025
  • Sign up
Powered by Ghost