Unit Test

Sponsored links
JavaScript/TypeScript

Top-Level function cannot be stubbed if it is exported by an asterisk

A top-level function is not a part of an object. If we need to stub it, we need to have an object that has the target fu...
JavaScript/TypeScript

What is the difference between Stub and Mock

In a unit test, we need to replace a real behavior with a test object but the variable name is sometimes xxxxStub for mo...
JavaScript/TypeScript

TypeScript Stub Date and timer friends functions with sinon

When Date class, timer friends functions like setTimeout, and setInterval are used in a function, we need to control the...
JavaScript/TypeScript

How to determine test values for unit testing

Are you a beginner at unit testing? Are you not confident enough to choose the test cases? You are not alone. Let's lear...
JavaScript/TypeScript

TypeScript Stub Top Level function by Sinon

Functions called in a different function are not always class members. They are often top-level functions which are not ...
JavaScript/TypeScript

How to mock fs.readdir and fs.readFile for unit testing

Reading a directory to get a file list and then, loading the file one by one. You might have seen such a function. If it...
JavaScript/TypeScript

How to inject user input data for unit tests

Some console applications require user inputs. For those inputs, we need to write unit tests. If we using readline modul...
JavaScript/TypeScript

How to start Unit Testing in TypeScript with mocha and chai

Writing unit tests is an important step to be an intermediate developer from a beginner. The developers who can't write ...
JavaScript/TypeScript

Chai Compare object array

I needed to write tests for object array but I spent time on how to write it. I write down how to do it to save my time ...
JavaScript/TypeScript

Mocha nested before after function call order

I use mocha for writing unit tests. My test sometimes fails because of misunderstanding the order of nested before, befo...
Sponsored links