Skip to content

Commit

Permalink
add jest test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrico1234 committed Aug 11, 2018
1 parent 6beb830 commit 0646ae9
Show file tree
Hide file tree
Showing 5 changed files with 327 additions and 105 deletions.
3 changes: 3 additions & 0 deletions .babelrc
@@ -0,0 +1,3 @@
{
"presets": ["es2015", "react"]
}
4 changes: 4 additions & 0 deletions jest-setup.js
@@ -0,0 +1,4 @@
const enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');

enzyme.configure({ adapter: new Adapter() });
10 changes: 8 additions & 2 deletions package.json
Expand Up @@ -11,12 +11,15 @@
"gatsby-source-filesystem": "^1.5.39",
"gatsby-transformer-json": "^1.0.20",
"lerna": "^2.11.0",
"react": "16.4.2",
"react-helmet": "^5.2.0",
"styled-components": "^3.3.3"
},
"devDependencies": {
"prettier": "^1.12.0",
"babel-jest": "^23.4.2"
"babel-jest": "^23.4.2",
"enzyme": "^3.4.1",
"enzyme-adapter-react-16": "^1.2.0"
},
"keywords": [
"gatsby"
Expand All @@ -26,7 +29,7 @@
"run:blog": "cd packages/blog && yarn develop",
"run:shop": "cd packages/shop && yarn develop",
"run:all": "npm-run-all --parallel run:blog run:shop",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest test"
},
"jest": {
"transform": {
Expand All @@ -36,6 +39,9 @@
"testPathIgnorePatterns": [
"/node_modules/",
"/.cache/"
],
"setupFiles": [
"./jest-setup.js"
]
},
"repository": {
Expand Down
21 changes: 21 additions & 0 deletions packages/blog/src/pages/blogitem.test.js
@@ -0,0 +1,21 @@
import React from 'react'
import { shallow } from 'enzyme'
import BlogItem from './blogItem'

describe('Layout component', () => {
const mockProps = {
pathContext: {
data: {
title: "mock title",
content: "mock content",
href: "google.com",
},
},
}

it('should render', () => {
const wrapper = shallow(<BlogItem {...mockProps} />)

expect(wrapper)
})
})

0 comments on commit 0646ae9

Please sign in to comment.