Article
Async Hooks are a core module in Node.js that provides an API to track the lifetime of asynchronous resources in a Node application. An asynchronous resource can be thought of as an object that has an associated callback. Examples include, but are not limited to: Promises, Timeouts, TCPWrap, UDP...
Allan Mogusu
Jest is a popular, open-source test framework for JavaScript. We can use Jest to create mocks in our test - objects that replace real objects in our code while it's being tested. In our previous series on unit testing techniques using Sinon.js, we covered how we can use Sinon....
Test "mocks" are objects that replace real objects while simulating their functions. A mock also has expectations about how the functions being tested will be used. In some unit test cases we may want to combine the functionality of spies, to observe a method's behavior under call, and...
In software testing, a "spy" records how a function is used when it is tested. This includes how many times it was called, whether it was called with the correct arguments, and what was returned. While tests are primarily used to validate the output of a function, sometimes...
Testing is a fundamental part of the software development process. When creating web applications, we make calls to third-party APIs, databases, or other services in our environment. Therefore, our tests must validate those request are sent and responses handled correctly. However, we may not always be able to communicate with...
Defining and calling functions are key practices for mastering JavaScript and most other programming languages. Usually, a function is defined before it is called in your code. Immediately-Invoked Function Expressions (IIFE), pronounced "iffy", are a common JavaScript pattern that executes a function instantly after it's defined. Developers primarily...
© 2013-2024 Stack Abuse. All rights reserved.