My Next.js (12.x) React (18.x) project includes Jest (28.x) for testing. While my tests in files like __tests__/Product.test.tsx
work smoothly, I encountered an issue when trying to reuse some utils across tests:
__tests__/util/my-test-helper.ts
export function setupSomeThing() {
return { foo: jest.fn() };
}
I imported this function into my tests, but the test runner displayed the following error message:
FAIL __tests__/util/my-test-helper.ts * Test suite failed to run Your test suite must contain at least one test.
How can I address this problem? The documentation on testing in Next.js doesn't provide guidance on this specific scenario.
What is the recommended approach or workaround for handling Jest tests in a Next.js environment?