Mocking in JavaScript tests with Sinon, Mocha and Jest

Lineke Kerckhoffs-Willems
Smart Apps
Published in
1 min readJul 24, 2018

--

Recently I ran into some issues with JavaScript testing in one of our projects. Since I had a hard time figuring out the solution and the internet didn’t help me enough, I thought I’d share my solution in a blogpost. The problem was that I had to mock AJAX calls done with jQuery or the fetch library. In this project we have 2 codebases where we use different frameworks for testing. One uses Jest for testing and jQuery for AJAX calls and the other uses Mocha and Chai for testing and the fetch library for AJAX calls. I will discuss my solutions for both frameworks.

For the full blog. View on https://www.egeniq.com/blog/mocking-javascript-tests-sinon-mocha-and-jest

--

--