Skip to content

Commit

Permalink
jest babel setup
Browse files Browse the repository at this point in the history
  • Loading branch information
bgonp committed Apr 8, 2021
1 parent dbf132e commit 6ceeab4
Show file tree
Hide file tree
Showing 8 changed files with 1,236 additions and 143 deletions.
8 changes: 8 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": ["@babel/preset-env"],
"plugins": [
"babel-plugin-transform-vite-meta-env",
["module-resolver", { "root": ["./src"] }],
["inline-dotenv", { "path": ".env.test", "unsafe": true }]
]
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.vscode
*.local
.env.*
dist
dist-ssr
node_modules
11 changes: 1 addition & 10 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
module.exports = {
moduleNameMapper: {
'^components/(.*)$': '<rootDir>/src/components/$1',
'^constants/(.*)$': '<rootDir>/src/constants/$1',
'^contexts/(.*)$': '<rootDir>/src/contexts/$1',
'^hooks/(.*)$': '<rootDir>/src/hooks/$1',
'^services/(.*)$': '<rootDir>/src/services/$1',
'^styles/(.*)$': '<rootDir>/src/styles/$1',
'^utils/(.*)$': '<rootDir>/src/utils/$1',
},
transform: {
'^.+\\.jsx?$': 'esbuild-jest-transform',
'^.+\\.jsx?$': 'babel-jest',
},
}
3 changes: 0 additions & 3 deletions jest.esbuild.js

This file was deleted.

1,328 changes: 1,212 additions & 116 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "vite",
"prepare": "husky install",
"serve": "vite preview",
"test": "eslint 'src/**' && jest -i",
"lint": "eslint --ignore-path .gitignore . --ext .js,.jsx",
"test": "npm run lint && jest -i",
"test:watch": "jest --watchAll"
},
"dependencies": {
Expand All @@ -17,8 +18,13 @@
"wouter": "2.7.4"
},
"devDependencies": {
"@babel/core": "7.13.15",
"@babel/preset-env": "7.13.15",
"@vitejs/plugin-react-refresh": "1.3.2",
"esbuild-jest-transform": "1.0.4",
"babel-jest": "26.6.3",
"babel-plugin-inline-dotenv": "1.6.0",
"babel-plugin-module-resolver": "4.1.0",
"babel-plugin-transform-vite-meta-env": "1.0.2",
"eslint": "7.23.0",
"eslint-config-standard": "16.0.2",
"eslint-plugin-import": "2.22.1",
Expand Down
14 changes: 6 additions & 8 deletions src/utils/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'

import { getVar } from 'utils/getVar'

firebase.initializeApp({
apiKey: getVar('VITE_FB_API_KEY'),
authDomain: getVar('VITE_FB_AUTH_DOMAIN'),
projectId: getVar('VITE_FB_PROJECT_ID'),
storageBucket: getVar('VITE_FB_STORAGE_BUCKET'),
messagingSenderId: getVar('VITE_FB_SENDER_ID'),
appId: getVar('VITE_FB_APP_ID'),
apiKey: import.meta.env.VITE_FB_API_KEY,
authDomain: import.meta.env.VITE_FB_AUTH_DOMAIN,
projectId: import.meta.env.VITE_FB_PROJECT_ID,
storageBucket: import.meta.env.VITE_FB_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FB_SENDER_ID,
appId: import.meta.env.VITE_FB_APP_ID,
})

const auth = firebase.auth()
Expand Down
3 changes: 0 additions & 3 deletions src/utils/getVar.js

This file was deleted.

0 comments on commit 6ceeab4

Please sign in to comment.