Skip to content

Commit

Permalink
Added Jest
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusps committed Apr 5, 2019
1 parent 5434610 commit 70705ea
Show file tree
Hide file tree
Showing 5 changed files with 1,872 additions and 44 deletions.
21 changes: 20 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"private": false,
"scripts": {
"check-types": "tsc",
"start": "webpack-dev-server --mode development"
"start": "webpack-dev-server --mode development",
"test": "jest"
},
"devDependencies": {
"@babel/core": "^7.4.3",
Expand All @@ -18,11 +19,15 @@
"@babel/preset-env": "^7.4.3",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@types/jest": "^24.0.11",
"@types/node": "^11.13.0",
"@types/react": "^16.8.12",
"@types/react-dom": "^16.8.3",
"babel-loader": "^8.0.5",
"html-webpack-plugin": "^3.2.0",
"jest": "^24.7.1",
"react-testing-library": "^6.1.1",
"ts-jest": "^24.0.1",
"typescript": "^3.4.1",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0",
Expand All @@ -31,5 +36,19 @@
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6"
},
"jest": {
"transform": {
".(ts|tsx)": "ts-jest"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
}
15 changes: 15 additions & 0 deletions src/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'
import { render } from 'react-testing-library'
import App from '../App'

describe('App component', () => {
it('should render', () => {
const component = render(<App />)
expect(component).toBeTruthy()
})

it('shoult match snapshot', () => {
const component = render(<App />)
expect(component.asFragment()).toMatchSnapshot()
})
})
9 changes: 9 additions & 0 deletions src/__tests__/__snapshots__/App.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`App component shoult match snapshot 1`] = `
<DocumentFragment>
<h1>
React Stellar
</h1>
</DocumentFragment>
`;
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"jsx": "preserve",
"jsx": "react",
"moduleResolution": "node",
"allowJs": true,
"noEmit": true,
Expand Down
Loading

0 comments on commit 70705ea

Please sign in to comment.