|
| 1 | +--- |
| 2 | +title: "GSoC '25 Week 10 Update by Nikhil Bhatt" |
| 3 | +excerpt: "Wrote 160 backend tests using Jest with controller mocking, and restructured several APIs for improved maintainability." |
| 4 | +category: "DEVELOPER NEWS" |
| 5 | +date: "2025-08-10" |
| 6 | +slug: "2025-08-10-gsoc-25-nikhilbhatt-week10" |
| 7 | +author: "@/constants/MarkdownFiles/authors/nikhil-bhatt.md" |
| 8 | +tags: "gsoc25,sugarlabs,week10,nikhilbhatt" |
| 9 | +image: "assets/Images/GSOC.png" |
| 10 | +--- |
| 11 | + |
| 12 | +<!-- markdownlint-disable --> |
| 13 | + |
| 14 | +# Week 10 Progress Report by Nikhil Bhatt |
| 15 | + |
| 16 | +**Project:** [Git backend for MusicBlocks](https://github.com/benikk/musicblocks-backend) |
| 17 | +**Mentors:** [Walter Bender](https://github.com/walterbender), [Sumit Srivastava](https://github.com/sum2it) |
| 18 | +**Reporting Period:** 2025-08-04 – 2025-08-10 |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## This Week's Achievements |
| 23 | + |
| 24 | +### Wrote Comprehensive Backend Tests with Jest |
| 25 | +This week, I focused heavily on **testing the backend** to ensure long-term stability and reliability. |
| 26 | + |
| 27 | +- Created **160 individual tests** ([view them here](https://github.com/BeNikk/musicblocks-backend/tree/main/tests)) covering core API functionality. |
| 28 | +- Used **Jest** for the testing framework, along with **mocking controllers** to isolate logic from external dependencies. |
| 29 | +- Tests cover both **happy paths** and **edge cases**, ensuring robust API behavior. |
| 30 | +- This significantly improves our **confidence in future code changes** without fear of breaking existing features. |
| 31 | + |
| 32 | +### Restructured and Improved APIs |
| 33 | +In parallel, I revisited some of our backend APIs for **better structuring and maintainability**. |
| 34 | + |
| 35 | +- Refactored route definitions for better **logical grouping**. |
| 36 | +- Improved **error handling** and **consistent response formats**. |
| 37 | +- Optimized certain request flows to reduce unnecessary API calls. |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## Challenges & How I Solved Them |
| 42 | + |
| 43 | +- **Challenge:** Maintaining test isolation without hitting actual APIs or databases. |
| 44 | + **Solution:** Used Jest mocks and stubs for controllers, ensuring tests run quickly and independently. |
| 45 | + |
| 46 | +- **Challenge:** Some APIs had inconsistent parameter handling. |
| 47 | + **Solution:** Standardized parameter validation and request body structures. |
| 48 | + |
| 49 | +- **Challenge:** Structuring large test suites while keeping them readable. |
| 50 | + **Solution:** Organized tests by feature/module and used descriptive naming conventions. |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +## Key Learnings |
| 55 | + |
| 56 | +- Mastered advanced **Jest mocking** techniques for controller and service layer isolation. |
| 57 | +- Learned the importance of **test coverage as a safety net** for refactoring. |
| 58 | +- Refactoring APIs not only improves code quality but also helps onboarding new contributors. |
| 59 | + |
| 60 | +--- |
| 61 | + |
| 62 | +## Next Week's Roadmap |
| 63 | + |
| 64 | +- Continue expanding test coverage to newly added backend features. |
| 65 | +- Start preparing **documentation** for the backend APIs. |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## Resources & References |
| 70 | + |
| 71 | +- [MusicBlocks Frontend Repo](https://github.com/sugarlabs/musicblocks) |
| 72 | +- [musicblocks-backend](https://github.com/benikk/musicblocks-backend) |
| 73 | +- [Jest Documentation](https://jestjs.io/docs/getting-started) |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +## Acknowledgments |
| 78 | + |
| 79 | +Thanks to my mentors and the Sugar Labs community for their support and feedback during the testing phase! |
| 80 | +This week was a major milestone towards making the backend **production-ready**. |
| 81 | +Looking forward to refining it even further next week. |
| 82 | + |
0 commit comments