[feat][m] - stub out next.js page and setup CI
This commit is contained in:
11
__tests__/index.test.tsx
Normal file
11
__tests__/index.test.tsx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { render } from '@testing-library/react'
|
||||||
|
import Index from '../pages/index'
|
||||||
|
|
||||||
|
test('renders homepage successfully', () => {
|
||||||
|
const { getByText } = render(<Index />)
|
||||||
|
const linkElement = getByText(
|
||||||
|
/Get started with Next.js/
|
||||||
|
)
|
||||||
|
expect(linkElement).toBeInTheDocument()
|
||||||
|
})
|
||||||
8
config/jest/cssTransform.js
Normal file
8
config/jest/cssTransform.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
process() {
|
||||||
|
return 'module.exports = {};'
|
||||||
|
},
|
||||||
|
getCacheKey() {
|
||||||
|
return 'cssTransform'
|
||||||
|
},
|
||||||
|
}
|
||||||
20
jest.config.js
Normal file
20
jest.config.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
module.exports = {
|
||||||
|
collectCoverageFrom: [
|
||||||
|
'**/*.{js,jsx,ts,tsx}',
|
||||||
|
'!**/*.d.ts',
|
||||||
|
'!**/node_modules/**',
|
||||||
|
],
|
||||||
|
setupFilesAfterEnv: ['<rootDir>/setupTests.js'],
|
||||||
|
testPathIgnorePatterns: ['/node_modules/', '/.next/'],
|
||||||
|
transform: {
|
||||||
|
'^.+\\.(js|jsx|ts|tsx)$': '<rootDir>/node_modules/babel-jest',
|
||||||
|
'^.+\\.css$': '<rootDir>/config/jest/cssTransform.js',
|
||||||
|
},
|
||||||
|
transformIgnorePatterns: [
|
||||||
|
'/node_modules/',
|
||||||
|
'^.+\\.module\\.(css|sass|scss)$',
|
||||||
|
],
|
||||||
|
moduleNameMapper: {
|
||||||
|
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
|
||||||
|
},
|
||||||
|
}
|
||||||
2
next-env.d.ts
vendored
Normal file
2
next-env.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/// <reference types="next" />
|
||||||
|
/// <reference types="next/types/global" />
|
||||||
12245
package-lock.json
generated
Normal file
12245
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@@ -5,11 +5,21 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start"
|
"start": "next start",
|
||||||
|
"test": "jest --watch"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"next": "9.4.2",
|
"next": "9.4.2",
|
||||||
"react": "16.13.1",
|
"react": "16.13.1",
|
||||||
"react-dom": "16.13.1"
|
"react-dom": "16.13.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@testing-library/jest-dom": "^5.8.0",
|
||||||
|
"@testing-library/react": "^10.0.4",
|
||||||
|
"@types/react": "^16.9.35",
|
||||||
|
"babel-jest": "^26.0.1",
|
||||||
|
"jest": "^26.0.1",
|
||||||
|
"react-test-renderer": "^16.13.1",
|
||||||
|
"typescript": "^3.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||||
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
|
||||||
export default (req, res) => {
|
export default (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
res.statusCode = 200
|
res.statusCode = 200
|
||||||
res.json({ name: 'John Doe' })
|
res.json({ name: 'John Doe' })
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@ export default function Home() {
|
|||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<p className="description">
|
<p className="description">
|
||||||
Get started by editing <code>pages/index.js</code>
|
Get started with Next.js
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div className="grid">
|
<div className="grid">
|
||||||
1
setupTests.js
Normal file
1
setupTests.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
import '@testing-library/jest-dom/extend-expect'
|
||||||
29
tsconfig.json
Normal file
29
tsconfig.json
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": false,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"jsx": "preserve"
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
],
|
||||||
|
"include": [
|
||||||
|
"next-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx", "setupTests.js", "jest.config.js", "config/jest/cssTransform.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user