Skip to content

Commit

Permalink
Merge pull request #2 from epeters-jrmngndr/npm-test
Browse files Browse the repository at this point in the history
Add React Unit Tests
  • Loading branch information
epeters-jrmngndr authored Aug 14, 2024
2 parents 9964cc6 + bd88011 commit 362dfe7
Show file tree
Hide file tree
Showing 12 changed files with 12,796 additions and 2,983 deletions.
18 changes: 18 additions & 0 deletions frontend/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
'@babel/preset-react',
],
plugins: [
'@babel/plugin-transform-class-properties',
'@babel/plugin-transform-runtime',
'@babel/plugin-transform-modules-commonjs'
],
};
13 changes: 13 additions & 0 deletions frontend/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// jest.config.js
module.exports = {
moduleNameMapper: {
"\\.(css|less|scss|sass)$": "identity-obj-proxy",
},
clearMocks: true,
coverageDirectory: "coverage",
testEnvironment: "jsdom",
transform: {
'^.+\\.jsx?$': 'babel-jest',
},
setupFilesAfterEnv: ['./jest.setup.cjs'],
};
13 changes: 13 additions & 0 deletions frontend/jest.setup.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Jest isn't compatible with more recent versions of react-markdown, and so this warning arises about future incompatibility. Suppress it, for now.
beforeAll(() => {
jest.spyOn(console, 'error').mockImplementation((msg) => {
if (msg.includes('Support for defaultProps will be removed from function components')) {
return;
}
console.error(msg);
});
});

afterAll(() => {
console.error.mockRestore();
});
Loading

0 comments on commit 362dfe7

Please sign in to comment.