diff --git a/.eslintignore b/.eslintignore
index cd8c9b4..cc8d5f6 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -5,3 +5,4 @@ out
next-env.d.ts
*.js
+__tests__
diff --git a/__tests__/components/HelloWorld.test.tsx b/__tests__/components/HelloWorld.test.tsx
new file mode 100644
index 0000000..cfff433
--- /dev/null
+++ b/__tests__/components/HelloWorld.test.tsx
@@ -0,0 +1,14 @@
+import React from 'react'
+import renderer from 'react-test-renderer'
+import HelloWorld from '../../components/HelloWorld'
+
+/**
+ * Example Test
+ *
+ * on first run it will generate a .snap file and after will compare result with it
+ */
+
+it('render a h1', () => {
+ const tree = renderer.create((Test)).toJSON()
+ expect(tree).toMatchSnapshot()
+})
diff --git a/__tests__/components/__snapshots__/HelloWorld.test.tsx.snap b/__tests__/components/__snapshots__/HelloWorld.test.tsx.snap
new file mode 100644
index 0000000..b9ab2d3
--- /dev/null
+++ b/__tests__/components/__snapshots__/HelloWorld.test.tsx.snap
@@ -0,0 +1,9 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`render a h1 1`] = `
+
+ Test
+
+`;
diff --git a/components/.gitkeep b/components/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/components/HelloWorld.tsx b/components/HelloWorld.tsx
new file mode 100644
index 0000000..b62583a
--- /dev/null
+++ b/components/HelloWorld.tsx
@@ -0,0 +1,20 @@
+import React from 'react'
+
+interface Props {
+ children: React.ReactNode
+}
+
+export default class HelloWorld extends React.Component {
+
+ public render() {
+ return (
+ <>
+ {this.props.children}
+
+ >
+ )
+ }
+}
diff --git a/jest.config.js b/jest.config.js
new file mode 100644
index 0000000..2c2b33f
--- /dev/null
+++ b/jest.config.js
@@ -0,0 +1,18 @@
+module.exports = {
+ collectCoverageFrom: [
+ '**/*.{js,jsx,ts,tsx}',
+ '!**/*.d.ts',
+ '!**/node_modules/**',
+ ],
+ testPathIgnorePatterns: ['/node_modules/', '/.next/'],
+ transform: {
+ '^.+\\.(js|jsx|ts|tsx)$': '/node_modules/babel-jest'
+ },
+ transformIgnorePatterns: [
+ '/node_modules/',
+ '^.+\\.module\\.(css|sass|scss)$',
+ ],
+ moduleNameMapper: {
+ '^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
+ },
+}
diff --git a/package.json b/package.json
index cb8b2fb..700cfaa 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,8 @@
"serve": "serve out",
"prod:server": "yarn build && yarn server",
"prod:static": "yarn build && yarn export && yarn serve",
- "lint": "eslint . --ext .ts,.tsx"
+ "lint": "eslint . --ext .ts,.tsx",
+ "test": "jest --config jext.config.js"
},
"dependencies": {
"@zeit/next-stylus": "^1.0.1",
diff --git a/tsconfig.json b/tsconfig.json
index 529240a..67a17fa 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,31 +1,32 @@
{
- "compilerOptions": {
- "target": "es5",
- "lib": [
- "dom",
- "dom.iterable",
- "esnext"
- ],
- "allowJs": true,
- "skipLibCheck": true,
- "strict": true,
- "forceConsistentCasingInFileNames": true,
- "noEmit": true,
- "esModuleInterop": true,
- "module": "esnext",
- "moduleResolution": "node",
- "resolveJsonModule": true,
- "isolatedModules": true,
- "jsx": "preserve"
- },
- "exclude": [
- "node_modules",
- "out"
- ],
- "include": [
- "next-env.d.ts",
- "styl/stylus.d.ts",
- "**/*.ts",
- "**/*.tsx"
- ]
+ "compilerOptions": {
+ "target": "es5",
+ "lib": [
+ "dom",
+ "dom.iterable",
+ "esnext"
+ ],
+ "allowJs": true,
+ "skipLibCheck": true,
+ "strict": true,
+ "forceConsistentCasingInFileNames": true,
+ "noEmit": true,
+ "esModuleInterop": true,
+ "module": "esnext",
+ "moduleResolution": "node",
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "jsx": "preserve"
+ },
+ "exclude": [
+ "node_modules",
+ "out",
+ "__tests__"
+ ],
+ "include": [
+ "next-env.d.ts",
+ "styl/stylus.d.ts",
+ "**/*.ts",
+ "**/*.tsx"
+ ]
}