jest

Jest Testing Advanced Tutorials With Live Example

Testing is a significant part of any software development. Testing helps detect the bug early and reduces the testing time. Earlier, we only focused on backend testing, but nowadays, there are a lot of frameworks available for fr…

How to mock/test IntersectionObserver using JEST

In this blog post, we will explore the Intersection Observer API, which provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with the top-level document’s viewport. …

Testing vanilla JavaScript with Jest

If you want to learn how to write javascript tests with jest, this book is for you. In this book, you’ll find real-world examples of jest testing, such as testing JQuery event/selector, localStorage, IntersectionObserver, timer,…

Advanced Sinon tutorial- Mocks, Spies & Stubs

This post will show you how to stub window/document properties like getElementById and custom functions. Let’s understand this with an example. Consider the following javascript code. In this code, I am getting the div and se…

Testing DOM using JSDOM in sinon/mocha

I’ll show you how to use JSDOM in your frontend testing in this article. When you run a unit test in node.js, you’ll notice that the document or window object isn’t accessible. As a result, testing it is extremely difficult…

Mocking- A guide to mock jQuery ajax using Jest

This is my personal favourite tip from the collection. In almost every project, we used an ajax call. Ajax testing is difficult because it is dependent on an external source. In this example, I’ll show you how to use jest to tes…

How to mock jQuery selector and return HTML element using JEST

When you have DOM dependency in your javascript application, you can easily mock the dom elements and return the HTML element. Consider the following code snippet for this example. The CSS class is added and removed based on th…

Testing with Jest: Awesome Tips and Tricks

Jest is a widely used testing framework that internally utilizes JSDOM. JSDOM is a library that parses and interacts with HTML similar to a browser. It implements web standards and allows mocking of window/document variables …

How to mock DOM element in Javascript/JQuery using Jest

Jest is a JavaScript testing framework developed and maintained by Facebook, Inc. It was designed and built by Christoph Nakazawa with a focus on simplicity and support for large web applications. Jest is widely used and compati…

How to mock module function using Jest

Jest is a JavaScript testing framework maintained by Facebook, Inc. designed and built by Christoph Nakazawa with a focus on simplicity and support for large web applications. It works with projects using Babel, TypeScript, Nod…

تحميل المزيد من المشاركات
لم يتم العثور على أي نتائج