Mocking Builder in Jest

We were using node v14 and after upgrading to v18, our Github action test started to fail. Locally they all pass.

What are you trying to accomplish
I want to make sure that locally and in the Github action all tests are passing


Github Action Tests

Local Tests

Code stack

Hello @adonis17,

Upgrading Node.js from version 14 to version 18 in a Gatsby application can introduce several changes and potential issues, especially if your codebase and dependencies rely on specific Node.js versions or if there have been breaking changes in Node.js itself. When tests pass locally but fail in a production environment, it can be challenging to diagnose the issue because there are differences between the two environments.

The error seems to be originating from jsdom module, which could be caused by your test setup if it’s calling window.close().

A simple jest.spyOn(window, "close").mockImplementation(jest.fn()); in the test setup could possibly fix the issue.

Also, you may want to check if jsdom dependencies are up to date.

Thank you so much for this info! :+1: