Skip to content

Commit

Permalink
Merge pull request #62 from hack4impact-calpoly/Jest
Browse files Browse the repository at this point in the history
Jest
  • Loading branch information
gracebw7 authored Mar 5, 2025
2 parents 2cf4b5a + 34d0903 commit 77c10ca
Show file tree
Hide file tree
Showing 14 changed files with 3,450 additions and 659 deletions.
31 changes: 31 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "current",
},
},
],
[
"@babel/preset-react",
{
runtime: "automatic", // Enables new JSX transform
},
],
"@babel/preset-typescript",
],

plugins: [
[
"module-resolver",
{
root: ["./src"],
alias: {
"@": "./src",
},
},
],
],
};
9 changes: 7 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ module.exports = {
testEnvironment: "jest-environment-jsdom", //use jsdom as the environment)
moduleNameMapper: {
"\\.css$": "identity-obj-proxy", // If you're using CSS modules
"^@/styles/(.*)$": "identity-obj-proxy",
},
transform: {
"^.+\\.tsx?$": "ts-jest", // Transpile .ts and .tsx files
//"^.+\\.tsx?$": "ts-jest", // Transpile .ts and .tsx files
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest", // Use babel-jest to transpile JS/JSX/TS/TSX files
},
setupFilesAfterEnv: ["@testing-library/jest-dom"],
setupFilesAfterEnv: [
"@testing-library/jest-dom",
"./jest.setup.js", // Add the path to the setup file
],
};
7 changes: 7 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { TextEncoder, TextDecoder } from "util";
import "dotenv/config"; // This will automatically load variables from .env file

global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;

global.structuredClone = global.structuredClone || ((obj) => JSON.parse(JSON.stringify(obj)));
Loading

0 comments on commit 77c10ca

Please sign in to comment.