From fbd2094ec35a0f063c3ce8612248da9d903b2e1e Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 5 Feb 2024 23:36:45 +0000 Subject: [PATCH] fix jest config --- package-lock.json | 2 +- package.json | 2 +- tests/{jest.config.ts => jest.config.js} | 12 ++++-------- 3 files changed, 6 insertions(+), 10 deletions(-) rename tests/{jest.config.ts => jest.config.js} (73%) diff --git a/package-lock.json b/package-lock.json index e0fbb4e..703ad41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ "typescript": "^5.3.3" }, "engines": { - "node": "20" + "node": "^20.6.0" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 0444099..df2ebb2 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "lint:css": "stylelint ./src/**/*.css", "lint": "npm run lint:js && npm run lint:css", "format": "prettier --write 'src/**/*.{ts,tsx,css}'", - "jest": "jest --coverage -c tests/jest.config.ts", + "jest": "jest --coverage -c tests/jest.config.js", "test": "NODE_ENV=test npm run prebuild && npm run lint && npm run typecheck && npm run jest", "new": "node --import tsx/esm ./scripts/new.ts", "favicon": "node --import tsx/esm ./scripts/favicon.ts", diff --git a/tests/jest.config.ts b/tests/jest.config.js similarity index 73% rename from tests/jest.config.ts rename to tests/jest.config.js index 21078db..b8a2604 100644 --- a/tests/jest.config.ts +++ b/tests/jest.config.js @@ -1,17 +1,13 @@ -import nextJest from 'next/jest' -import type { Config } from 'jest' +import nextJest from 'next/jest.js' const createJestConfig = nextJest({ - // Provide the path to your Next.js app to load next.config.js and .env files in your test environment dir: './' }) -// Add any custom config to be passed to Jest -const customJestConfig: Config = { - rootDir: '../', // = / - // Add more setup options before each test is run +/** @type {import('jest').Config} */ +const customJestConfig = { + rootDir: '../', setupFilesAfterEnv: ['/tests/jest.setup.tsx'], - // if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work moduleDirectories: ['node_modules', '/src'], testEnvironment: 'jsdom', moduleNameMapper: {