Skip to content

Commit

Permalink
Merge pull request #753 from WildMeOrg/unit_test
Browse files Browse the repository at this point in the history
add unit test for frontend
  • Loading branch information
TanyaStere42 authored Sep 23, 2024
2 parents 26770c3 + 4abdd4a commit 2a2ad8e
Show file tree
Hide file tree
Showing 11 changed files with 420 additions and 851 deletions.
27 changes: 26 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default [
react: {
version: "detect"
}
},
},

rules: {
"semi": 2,
"react/prop-types": 0,
Expand Down Expand Up @@ -56,4 +57,28 @@ export default [

},
},
{
files: ['frontend/babel.config.js', 'frontend/jest.config.js', 'babel.config.js'], // Specify the config files
languageOptions: {
globals: {
require: "readonly",
module: "readonly",
__dirname: "readonly",
process: "readonly",
},
},
},
{
files: ["**/__tests__/**/*.{js,jsx}", "**/*.test.{js,jsx}"],
languageOptions: {
globals: {
jest: "readonly", // Define Jest-specific globals
test: "readonly",
expect: "readonly",
},
},
rules: {
"react/react-in-jsx-scope": 0, // Disable React in scope for JSX cuz we are using React 17+
}
}
];
3 changes: 3 additions & 0 deletions frontend/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ["@babel/preset-env", "@babel/preset-react"],
};
14 changes: 14 additions & 0 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
testMatch: [
"**/__tests__/**/*.[jt]s?(x)", // Looks inside __tests__ folders
"**/?(*.)+(spec|test).[tj]s?(x)", // Looks for .spec.js/.test.js files
],
transform: {
"^.+\\.[t|j]sx?$": "babel-jest",
},
transformIgnorePatterns: ["/node_modules/(?!(axios)).+\\.js$"],
testEnvironment: "jsdom", // Set the environment for testing React components
moduleNameMapper: {
"^axios$": require.resolve("axios"),
},
};
Loading

0 comments on commit 2a2ad8e

Please sign in to comment.