mirror of
https://github.com/kremalicious/ipfs.git
synced 2024-11-22 01:37:07 +01:00
setup testing
This commit is contained in:
parent
115b6ff4a0
commit
5e921e8b40
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,4 +4,5 @@ npm-debug.log
|
|||||||
.next
|
.next
|
||||||
out
|
out
|
||||||
build
|
build
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
coverage
|
@ -3,7 +3,10 @@ sudo: required
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js: node
|
node_js: node
|
||||||
|
|
||||||
cache: npm
|
cache:
|
||||||
|
npm: true
|
||||||
|
directories:
|
||||||
|
- .next/cache
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
# Fixes an issue where the max file watch count is exceeded, triggering ENOSPC
|
# Fixes an issue where the max file watch count is exceeded, triggering ENOSPC
|
||||||
|
23
jest.config.js
Normal file
23
jest.config.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
module.exports = {
|
||||||
|
preset: 'ts-jest/presets/js-with-ts',
|
||||||
|
setupFilesAfterEnv: ['<rootDir>/jest/setup.ts'],
|
||||||
|
globals: {
|
||||||
|
'ts-jest': {
|
||||||
|
tsConfig: 'jest.tsconfig.json'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
moduleNameMapper: {
|
||||||
|
'.+\\.(css|styl|less|sass|scss)$': '<rootDir>/jest/__mocks__/styleMock.js',
|
||||||
|
'.+\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
||||||
|
'<rootDir>/jest/__mocks__/fileMock.js',
|
||||||
|
'\\.svg': '<rootDir>/jest/__mocks__/svgrMock.js'
|
||||||
|
},
|
||||||
|
testPathIgnorePatterns: [
|
||||||
|
'<rootDir>/.next',
|
||||||
|
'<rootDir>/node_modules',
|
||||||
|
'<rootDir>/build',
|
||||||
|
'<rootDir>/coverage'
|
||||||
|
],
|
||||||
|
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/@types/**/*'],
|
||||||
|
collectCoverage: true
|
||||||
|
}
|
12
jest.tsconfig.json
Normal file
12
jest.tsconfig.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"jsx": "react",
|
||||||
|
"allowJs": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"target": "es5"
|
||||||
|
}
|
||||||
|
}
|
1
jest/__mocks__/fileMock.js
Normal file
1
jest/__mocks__/fileMock.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = 'test-file-stub'
|
1
jest/__mocks__/styleMock.js
Normal file
1
jest/__mocks__/styleMock.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = {}
|
1
jest/__mocks__/svgrMock.js
Normal file
1
jest/__mocks__/svgrMock.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = 'svg'
|
1
jest/setup.ts
Normal file
1
jest/setup.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
import '@testing-library/jest-dom/extend-expect'
|
13
package.json
13
package.json
@ -6,8 +6,11 @@
|
|||||||
"start": "next dev",
|
"start": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"serve": "next start",
|
"serve": "next start",
|
||||||
"test": "eslint --ignore-path .gitignore '**/*.{js,jsx,ts,tsx}'",
|
"test": "npm run lint && NODE_ENV=test jest",
|
||||||
"format": "prettier --ignore-path .gitignore '**/*.{css,yml,js,jsx,ts,tsx,json}' --write"
|
"test:watch": "npm run lint && NODE_ENV=test jest --watch",
|
||||||
|
"lint": "eslint --ignore-path .gitignore --ext .js .",
|
||||||
|
"format": "prettier --ignore-path .gitignore '**/*.{css,yml,js,jsx,ts,tsx,json}' --write",
|
||||||
|
"analyze": "ANALYZE=true next build"
|
||||||
},
|
},
|
||||||
"author": "Matthias Kretschmann <m@kretschmann.io>",
|
"author": "Matthias Kretschmann <m@kretschmann.io>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -24,6 +27,10 @@
|
|||||||
"use-dark-mode": "^2.3.1"
|
"use-dark-mode": "^2.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@next/bundle-analyzer": "^9.1.4",
|
||||||
|
"@testing-library/jest-dom": "^4.2.4",
|
||||||
|
"@testing-library/react": "^9.3.2",
|
||||||
|
"@types/jest": "^24.0.23",
|
||||||
"@types/next-seo": "^1.10.0",
|
"@types/next-seo": "^1.10.0",
|
||||||
"@types/node": "^12.12.14",
|
"@types/node": "^12.12.14",
|
||||||
"@types/react": "^16.9.15",
|
"@types/react": "^16.9.15",
|
||||||
@ -35,8 +42,10 @@
|
|||||||
"eslint-plugin-jsx-a11y": "^6.2.3",
|
"eslint-plugin-jsx-a11y": "^6.2.3",
|
||||||
"eslint-plugin-prettier": "^3.1.1",
|
"eslint-plugin-prettier": "^3.1.1",
|
||||||
"eslint-plugin-react": "^7.17.0",
|
"eslint-plugin-react": "^7.17.0",
|
||||||
|
"jest": "^24.9.0",
|
||||||
"postcss-preset-env": "^6.7.0",
|
"postcss-preset-env": "^6.7.0",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
|
"ts-jest": "^24.2.0",
|
||||||
"typescript": "^3.7.3"
|
"typescript": "^3.7.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
10
src/__tests__/Layout.test.tsx
Normal file
10
src/__tests__/Layout.test.tsx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { render } from '@testing-library/react'
|
||||||
|
import Layout from '../Layout'
|
||||||
|
|
||||||
|
describe('Layout', () => {
|
||||||
|
it('renders without crashing', () => {
|
||||||
|
const { container } = render(<Layout pageTitle="Hello">Hello</Layout>)
|
||||||
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
|
})
|
||||||
|
})
|
10
src/__tests__/Loader.test.tsx
Normal file
10
src/__tests__/Loader.test.tsx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { render } from '@testing-library/react'
|
||||||
|
import Loader from '../components/Loader'
|
||||||
|
|
||||||
|
describe('Loader', () => {
|
||||||
|
it('renders without crashing', () => {
|
||||||
|
const { container } = render(<Loader message="Hello" />)
|
||||||
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
|
})
|
||||||
|
})
|
11
src/__tests__/index.test.tsx
Normal file
11
src/__tests__/index.test.tsx
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { render, wait } from '@testing-library/react'
|
||||||
|
import Home from '../pages'
|
||||||
|
|
||||||
|
describe('Home', () => {
|
||||||
|
it('renders without crashing', async () => {
|
||||||
|
const { container } = render(<Home />)
|
||||||
|
await wait()
|
||||||
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
|
})
|
||||||
|
})
|
@ -22,7 +22,7 @@ export default function Add() {
|
|||||||
const [message] = useState()
|
const [message] = useState()
|
||||||
const [error, setError] = useState()
|
const [error, setError] = useState()
|
||||||
|
|
||||||
async function handleOnDrop(acceptedFiles: FileDropzone[]) {
|
async function handleOnDrop(acceptedFiles: FileDropzone[]): Promise<any> {
|
||||||
if (!acceptedFiles) return
|
if (!acceptedFiles) return
|
||||||
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
Loading…
Reference in New Issue
Block a user