Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Add frontend tests to pre-commit and Makefile. (#1549)

Leo6013faeec5bb
diff --git a/Makefile b/Makefile
index 8db71efe2e..bb7abcdbe8 100644
--- a/Makefile
+++ b/Makefile
@@ -160,6 +160,13 @@ lint:
@$(MAKE) -s lint-frontend
@$(MAKE) -s lint-backend
+test-frontend:
+ @echo "$(YELLOW)Running tests for frontend...$(RESET)"
+ @cd frontend && npm run test
+
+test:
+ @$(MAKE) -s test-frontend
+
build-frontend:
@echo "$(YELLOW)Building frontend...$(RESET)"
@cd frontend && npm run build
diff --git a/frontend/.husky/pre-commit b/frontend/.husky/pre-commit
index 552a158849..1db182a1c5 100755
--- a/frontend/.husky/pre-commit
+++ b/frontend/.husky/pre-commit
@@ -1,3 +1,4 @@
#!/bin/sh
cd frontend
npx lint-staged
+npm run test
diff --git a/frontend/package.json b/frontend/package.json
index 8f9713ce76..32256a825a 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -39,7 +39,7 @@
"scripts": {
"start": "vite",
"build": "tsc && vite build",
- "test": "vitest",
+ "test": "vitest run",
"preview": "vite preview",
"make-i18n": "node scripts/make-i18n-translations.cjs",
"prelint": "npm run make-i18n",
@@ -48,7 +48,7 @@
},
"husky": {
"hooks": {
- "pre-commit": "lint-staged"
+ "pre-commit": "npm run test && lint-staged"
}
},
"lint-staged": {
diff --git a/frontend/src/components/modals/settings/SettingsModal.test.tsx b/frontend/src/components/modals/settings/SettingsModal.test.tsx
index ba540b2a20..d06dccff8d 100644
--- a/frontend/src/components/modals/settings/SettingsModal.test.tsx
+++ b/frontend/src/components/modals/settings/SettingsModal.test.tsx
@@ -190,7 +190,7 @@ describe("SettingsModal", () => {
userEvent.click(saveButton);
});
- expect(toastSpy).toHaveBeenCalledTimes(1);
+ expect(toastSpy).toHaveBeenCalledTimes(2);
});
it("should change the language", async () => {