[feat][m] - stub out next.js page and setup CI

This commit is contained in:
Gift Egwuenu 2020-05-25 14:49:52 +01:00
parent 12026d947d
commit 96e1c4d6ae
12 changed files with 12333 additions and 5535 deletions

3
.babelrc Normal file
View File

@ -0,0 +1,3 @@
{
"presets": ["next/babel"]
}

11
__tests__/index.test.tsx Normal file
View 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()
})

View File

@ -0,0 +1,8 @@
module.exports = {
process() {
return 'module.exports = {};'
},
getCacheKey() {
return 'cssTransform'
},
}

20
jest.config.js Normal file
View 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
View File

@ -0,0 +1,2 @@
/// <reference types="next" />
/// <reference types="next/types/global" />

12245
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5,11 +5,21 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
"start": "next start",
"test": "jest --watch"
},
"dependencies": {
"next": "9.4.2",
"react": "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"
}
}

View File

@ -1,6 +1,7 @@
// 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.json({ name: 'John Doe' })
}

View File

@ -14,7 +14,7 @@ export default function Home() {
</h1>
<p className="description">
Get started by editing <code>pages/index.js</code>
Get started with Next.js
</p>
<div className="grid">

1
setupTests.js Normal file
View File

@ -0,0 +1 @@
import '@testing-library/jest-dom/extend-expect'

29
tsconfig.json Normal file
View 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"
]
}

5532
yarn.lock

File diff suppressed because it is too large Load Diff