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... 2022.05.04 JavaScript/TypeScript
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... 2022.04.29 JavaScript/TypeScript
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... 2022.04.15 JavaScript/TypeScript
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... 2022.04.04 JavaScript/TypeScript
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 ... 2022.04.01 JavaScript/TypeScript
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... 2022.03.30 JavaScript/TypeScript
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... 2022.03.28 JavaScript/TypeScript
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 ... 2022.03.23 JavaScript/TypeScript
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 ... 2022.02.23 JavaScript/TypeScript
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... 2022.01.21 JavaScript/TypeScript