mirror of
https://github.com/Aviortheking/next-template.git
synced 2025-04-22 18:52:09 +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
|
||||
*.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",
|
||||
"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",
|
||||
|
@ -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"
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user