Skip to content

Commit

Permalink
Add jest snapshot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Fischer authored and xitij2000 committed Jul 17, 2018
1 parent 4b4a863 commit b7d16b9
Show file tree
Hide file tree
Showing 11 changed files with 3,373 additions and 145 deletions.
14 changes: 13 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,17 @@
}
],
"babel-preset-react"
]
],
"env": {
"test": {
"presets": [
[
"env",
{
"modules": "commonjs",
}
]
]
}
},
}
16 changes: 16 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
"globals": {
"gettext": (t) => { return t; },
},
"modulePaths": [
"common/static/common/js/components",
],
"testMatch": [
"**/ProblemBrowser/**/*.test.jsx",
"common/static/common/js/components/**/?(*.)+(spec|test).js?(x)",
],
"transform": {
"^.+\\.jsx$": "babel-jest",
"^.+\\.js$": "babel-jest",
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import Main from './Main.jsx';
import renderer from 'react-test-renderer';

test('My first demo test', () => {
const component = renderer.create(<Main></Main>);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`My first demo test 1`] = `
<div
className="problem-browser"
>
<button
className="btn"
onBlur={[Function]}
onClick={[Function]}
onKeyDown={[Function]}
type="button"
>
Select a section or problem
</button>
<input
disabled={true}
name="problem-location"
type="text"
/>
</div>
`;
Loading

0 comments on commit b7d16b9

Please sign in to comment.