Skip to content

Commit

Permalink
chore: add jest config & setup to mock envs
Browse files Browse the repository at this point in the history
  • Loading branch information
1emu committed Apr 17, 2024
1 parent 46aa6f2 commit 7776e64
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 3 deletions.
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-typescript'],
}
7 changes: 7 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
jest.mock('./src/constants/heroku', () => ({
HEROKU_APP_NAME: 'test',
}))
jest.mock('./src/constants/grants', () => ({
GRANT_VP_THRESHOLD: null,
MAX_LOWER_TIER_GRANT_FUNDING: 20000,
}))
4 changes: 4 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"jest": {
"watchman": false,
"setupFilesAfterEnv": ["<rootDir>/jest.setup.ts"],
"roots": [
"<rootDir>/src/"
],
"testEnvironment": "node"
},
"repository": {
"type": "git",
"url": "git+https://github.com/decentraland/governance-ui.git"
Expand Down Expand Up @@ -67,6 +75,9 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@babel/preset-env": "^7.24.4",
"@babel/preset-typescript": "^7.24.1",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@storybook/addon-essentials": "^7.4.0",
Expand Down Expand Up @@ -98,6 +109,7 @@
"@typescript-eslint/parser": "^6.11.0",
"@vitejs/plugin-basic-ssl": "^1.0.2",
"@vitejs/plugin-react-swc": "^3.3.2",
"babel-jest": "^29.7.0",
"concurrently": "^6.0.0",
"dotenv": "^16.3.1",
"eslint": "^8.15.0",
Expand Down Expand Up @@ -129,4 +141,4 @@
"*.{js,jsx,ts,tsx}": "eslint --cache --fix",
"*.{js,jsx,ts,tsx,css,json}": "prettier --write"
}
}
}
3 changes: 2 additions & 1 deletion src/clients/Governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import snakeCase from 'lodash/snakeCase'

import { SpecState } from '../components/Debug/UploadBadgeSpec'
import { GOVERNANCE_API } from '../constants'
import { HEROKU_APP_NAME } from '../constants/heroku'
import {
DetailedScores,
SnapshotConfig,
Expand Down Expand Up @@ -98,7 +99,7 @@ export type GetProposalsFilter = ProposalListFilter & {
}

const getGovernanceApiUrl = () => {
if (import.meta.env.VITE_HEROKU_APP_NAME) {
if (HEROKU_APP_NAME) {
return `https://governance.decentraland.vote/api`
}

Expand Down
1 change: 1 addition & 0 deletions src/constants/heroku.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const HEROKU_APP_NAME = import.meta.env.VITE_HEROKU_APP_NAME
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src", "vite.config.ts", "scripts"],
"include": ["src", "vite.config.ts", "scripts", "babel.config.js", "jest.setup.ts"],
"exclude": ["node_modules", "**/node_modules/*"],
"references": [{ "path": "./tsconfig.node.json" }]
}

0 comments on commit 7776e64

Please sign in to comment.