yarn create vite-
-
Save mistical2008/cd10d3db011eba77db95e574008a68ea to your computer and use it in GitHub Desktop.
vite + react + @swc/jest
yarn add --dev @swc/core @swc/jest @testing-library/jest-dom @testing-library/react @types/jest eslint eslint-config-prettier eslint-plugin-jest-dom eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-testing-library jest prettier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "env": { | |
| "browser": true, | |
| "es2021": true, | |
| "jest": true, | |
| "node": true | |
| }, | |
| "extends": [ | |
| "eslint:recommended", | |
| "plugin:react/recommended", | |
| "plugin:react-hooks/recommended", | |
| "plugin:testing-library/react", | |
| "plugin:jest-dom/recommended", | |
| "plugin:prettier/recommended" | |
| ], | |
| "parserOptions": { | |
| "ecmaFeatures": { | |
| "jsx": true | |
| }, | |
| "ecmaVersion": "latest", | |
| "sourceType": "module" | |
| }, | |
| "rules": { | |
| "react/react-in-jsx-scope": "off" | |
| }, | |
| "settings": { | |
| "react": { | |
| "version": "latest" | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "arrowParens": "avoid", | |
| "printWidth": 90, | |
| "singleQuote": true, | |
| "semi": false | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| process: () => "module.exports = 'test-file-stub'", | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| clearMocks: true, | |
| moduleNameMapper: { | |
| '^~/(.*)$': '<rootDir>/src/$1', | |
| }, | |
| setupFilesAfterEnv: ['<rootDir>/jest.setup.js'], | |
| testEnvironment: 'jest-environment-jsdom', | |
| transform: { | |
| '^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': | |
| '<rootDir>/__mocks__/file-transformer.js', | |
| '^.+\\.(css|scss|sass|less)$': '<rootDir>/__mocks__/style-transformer.js', | |
| '^.+\\.(t|j)sx?$': [ | |
| '@swc/jest', | |
| { | |
| jsc: { | |
| parser: { | |
| syntax: 'ecmascript', | |
| jsx: true, | |
| }, | |
| transform: { | |
| react: { | |
| runtime: 'automatic', | |
| }, | |
| }, | |
| }, | |
| }, | |
| ], | |
| }, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import '@testing-library/jest-dom/extend-expect' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "compilerOptions": { | |
| "baseUrl": ".", | |
| "paths": { | |
| "~/*": ["./src/*"] | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "lint": "eslint .", | |
| "lint:fix": "eslint . --fix", | |
| "test": "jest", | |
| "test:coverage": "jest --coverage && open coverage/lcov-report/index.html", | |
| "test:watch": "jest --watch" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| process: () => 'module.exports = {}', | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import react from '@vitejs/plugin-react' | |
| import path from 'node:path' | |
| export default { | |
| plugins: [react()], | |
| resolve: { | |
| alias: { | |
| '~': path.resolve(__dirname, 'src'), | |
| }, | |
| }, | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment