Skip to content

Commit

Permalink
Setup unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jpangelle committed Aug 25, 2024
1 parent f6a5cf4 commit a995d26
Show file tree
Hide file tree
Showing 7 changed files with 1,571 additions and 32 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/redeem.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: yarn

- name: Run unit tests
run: yarn test

- name: Install xvfb and fluxbox
run: |
sudo apt-get install --no-install-recommends -y \
Expand All @@ -27,6 +33,7 @@ jobs:
- name: Run e2e tests
uses: cypress-io/github-action@v6
with:
install: false
headed: true
command: yarn cypress:run
browser: chrome
Expand Down
14 changes: 14 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Config } from "jest";
import nextJest from "next/jest.js";

const createJestConfig = nextJest({
dir: "./",
});

const config: Config = {
coverageProvider: "v8",
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
testEnvironment: "node",
};

export default createJestConfig(config);
1 change: 1 addition & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "@testing-library/jest-dom";
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "jest",
"test:watch": "jest --watch",
"cypress:run": "CYPRESS_REMOTE_DEBUGGING_PORT=9222 cypress run --browser chrome --headed"
},
"dependencies": {
Expand All @@ -19,14 +21,21 @@
"wagmi": "^2.12.5"
},
"devDependencies": {
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.0",
"@types/jest": "^29.5.12",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"cypress": "12.17.3",
"eslint": "^8",
"eslint-config-next": "14.2.5",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"ts-node": "^10.9.2",
"typescript": "^5"
},
"resolutions": {
Expand Down
8 changes: 8 additions & 0 deletions src/utilities.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { parseUnits } from "viem";
import { formatAmount } from "./utilities";

it("should format amount", () => {
const amount = parseUnits("1000", 18);
const formattedAmount = formatAmount(amount, 18);
expect(formattedAmount).toBe("1,000.00");
});
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "cypress.config.ts"]
}
Loading

0 comments on commit a995d26

Please sign in to comment.