build: add scaffolding for test

This commit is contained in:
unix
2020-04-14 19:07:51 +08:00
parent 2f86f926c3
commit fe13183be5
7 changed files with 2415 additions and 51 deletions

View File

@@ -4,3 +4,4 @@ examples/*
dist/*
public/*
scripts/*
tests/*

15
.jest.config.js Normal file
View File

@@ -0,0 +1,15 @@
module.exports = {
verbose: true,
setupFiles: ['./tests/setup.js'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
testPathIgnorePatterns: ['/pages/', '/dist/', '/lib/'],
transform: {
'^.+\\.tsx?$': ['babel-jest', { configFile: './tests/.babelrc.js' }],
},
testRegex: '.*\\.test\\.(j|t)sx?$',
}

View File

@@ -15,6 +15,8 @@
"contributor-collect": "node scripts/collect-contributors.js",
"clear": "rm -rf dist",
"lint": "eslint \"{components,lib}/**/*.{js,ts,tsx}\"",
"test": "jest --config .jest.config.js --no-cache",
"test-update": "jest --config .jest.config.js --no-cache --update-snapshot",
"now-build": "yarn run docs-build",
"build": "yarn run clear && webpack --config scripts/webpack.config.js && tsc -p ./scripts",
"release": "yarn run build && yarn publish --access public --non-interactive"
@@ -49,29 +51,36 @@
"@mapbox/rehype-prism": "^0.4.0",
"@mdx-js/loader": "^1.5.7",
"@next/mdx": "^9.2.2",
"@types/enzyme": "^3.10.5",
"@types/jest": "^25.2.1",
"@types/react": "^16.9.22",
"@types/react-color": "^3.0.1",
"@types/react-dom": "^16.9.5",
"@types/styled-jsx": "^2.2.8",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.24.0",
"babel-jest": "^25.3.0",
"babel-loader": "^8.0.6",
"dotenv": "^8.2.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"eslint": "^6.8.0",
"eslint-config-ts-lambdas": "^1.2.0",
"eslint-plugin-react": "^7.19.0",
"extract-mdx-metadata": "^1.0.0",
"fs-extra": "^8.1.0",
"graphql-request": "^1.8.2",
"jest": "^25.3.0",
"next": "^9.3.4",
"react": "^16.13.0",
"react-color": "^2.18.0",
"react-dom": "^16.13.0",
"react-live": "^2.2.2",
"styled-jsx": "^3.2.4",
"styled-jsx": "^3.2.5",
"ts-jest": "^25.3.1",
"typescript": "^3.8.2",
"webpack": "^4.41.6",
"webpack-cli": "^3.3.11"
},
"dependencies": {}
}
}

View File

@@ -0,0 +1,36 @@
{
"compilerOptions": {
"baseUrl": "../",
"outDir": "../dist",
"declaration": true,
"emitDeclarationOnly": true,
"strictNullChecks": true,
"moduleResolution": "node",
"esModuleInterop": true,
"experimentalDecorators": true,
"jsx": "react",
"noUnusedParameters": true,
"noUnusedLocals": true,
"noImplicitAny": true,
"target": "es6",
"lib": [
"dom",
"es2017"
],
"skipLibCheck": true,
"allowJs": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"resolveJsonModule": true,
"isolatedModules": true
},
"files": [
"../components/index.ts"
],
"exclude": [
"node_modules",
"lib",
"es"
]
}

4
tests/.babelrc.js Normal file
View File

@@ -0,0 +1,4 @@
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
plugins: ['styled-jsx/babel-test'],
}

4
tests/setup.js Normal file
View File

@@ -0,0 +1,4 @@
const enzyme = require('enzyme')
const Adapter = require('enzyme-adapter-react-16')
enzyme.configure({ adapter: new Adapter() })

2393
yarn.lock

File diff suppressed because it is too large Load Diff