mirror of
https://github.com/Aviortheking/next-template.git
synced 2025-04-23 03:02:08 +00:00
Added Example Component and testing framework
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
31692dfbd4
commit
f5cdda822c
@ -5,3 +5,4 @@ out
|
|||||||
|
|
||||||
next-env.d.ts
|
next-env.d.ts
|
||||||
*.js
|
*.js
|
||||||
|
__tests__
|
||||||
|
14
__tests__/components/HelloWorld.test.tsx
Normal file
14
__tests__/components/HelloWorld.test.tsx
Normal file
@ -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((<HelloWorld>Test</HelloWorld>)).toJSON()
|
||||||
|
expect(tree).toMatchSnapshot()
|
||||||
|
})
|
@ -0,0 +1,9 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`render a h1 1`] = `
|
||||||
|
<h1
|
||||||
|
className="jsx-3954099876"
|
||||||
|
>
|
||||||
|
Test
|
||||||
|
</h1>
|
||||||
|
`;
|
20
components/HelloWorld.tsx
Normal file
20
components/HelloWorld.tsx
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
children: React.ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class HelloWorld extends React.Component<Props> {
|
||||||
|
|
||||||
|
public render() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h1>{this.props.children}</h1>
|
||||||
|
<style jsx>{`
|
||||||
|
h1
|
||||||
|
font-weight 700
|
||||||
|
`}</style>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
18
jest.config.js
Normal file
18
jest.config.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
module.exports = {
|
||||||
|
collectCoverageFrom: [
|
||||||
|
'**/*.{js,jsx,ts,tsx}',
|
||||||
|
'!**/*.d.ts',
|
||||||
|
'!**/node_modules/**',
|
||||||
|
],
|
||||||
|
testPathIgnorePatterns: ['/node_modules/', '/.next/'],
|
||||||
|
transform: {
|
||||||
|
'^.+\\.(js|jsx|ts|tsx)$': '<rootDir>/node_modules/babel-jest'
|
||||||
|
},
|
||||||
|
transformIgnorePatterns: [
|
||||||
|
'/node_modules/',
|
||||||
|
'^.+\\.module\\.(css|sass|scss)$',
|
||||||
|
],
|
||||||
|
moduleNameMapper: {
|
||||||
|
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
|
||||||
|
},
|
||||||
|
}
|
@ -10,7 +10,8 @@
|
|||||||
"serve": "serve out",
|
"serve": "serve out",
|
||||||
"prod:server": "yarn build && yarn server",
|
"prod:server": "yarn build && yarn server",
|
||||||
"prod:static": "yarn build && yarn export && yarn serve",
|
"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": {
|
"dependencies": {
|
||||||
"@zeit/next-stylus": "^1.0.1",
|
"@zeit/next-stylus": "^1.0.1",
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"out"
|
"out",
|
||||||
|
"__tests__"
|
||||||
],
|
],
|
||||||
"include": [
|
"include": [
|
||||||
"next-env.d.ts",
|
"next-env.d.ts",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user