-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
67 additions
and
33 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const nextJest = require("next/jest") | ||
|
||
const createJestConfig = nextJest({ | ||
dir: "./", | ||
}) | ||
|
||
const customJestConfig = { | ||
moduleNameMapper: { | ||
"^@/(.*)$": "<rootDir>/$1", | ||
}, | ||
setupFiles: ["./jest.polyfills.js"], | ||
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"], | ||
testEnvironment: "jest-environment-jsdom", | ||
} | ||
|
||
module.exports = createJestConfig(customJestConfig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// jest.polyfills.js | ||
/** | ||
* @note The block below contains polyfills for Node.js globals | ||
* required for Jest to function when running JSDOM tests. | ||
* These HAVE to be require's and HAVE to be in this exact | ||
* order, since "undici" depends on the "TextEncoder" global API. | ||
* | ||
* Consider migrating to a more modern test runner if | ||
* you don't want to deal with this. | ||
*/ | ||
|
||
const { TextDecoder, TextEncoder } = require("node:util") | ||
|
||
Object.defineProperties(globalThis, { | ||
TextDecoder: { value: TextDecoder }, | ||
TextEncoder: { value: TextEncoder }, | ||
}) | ||
|
||
//const { TransformStream, ReadableStream } = require('web-streams-polyfill'); | ||
// Object.defineProperties(globalThis, { | ||
// TransformStream: { value: TransformStream }, | ||
// ReadableStream: { value: ReadableStream }, | ||
// }); | ||
// Break API requests during tests | ||
//const { Blob, File } = require('node:buffer') | ||
// const { fetch, Headers, FormData, Request, Response } = require('undici') | ||
// | ||
// Object.defineProperties(globalThis, { | ||
// fetch: { value: fetch, writable: true }, | ||
// Blob: { value: Blob }, | ||
// File: { value: File }, | ||
// Headers: { value: Headers }, | ||
// FormData: { value: FormData }, | ||
// Request: { value: Request }, | ||
// Response: { value: Response }, | ||
// }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Learn more: https://github.com/testing-library/jest-dom | ||
import "@testing-library/jest-dom" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters