-
Notifications
You must be signed in to change notification settings - Fork 0
test(KP-448): improve test config and introduce ts in /shared #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
613845a to
0829147
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new TypeScript-enabled shared code directory and modernizes the test and build infrastructure. The main purpose is to enable better code sharing across different parts of the application by creating a /shared folder with TypeScript support, while also improving the CI/CD pipeline and Jest configuration for better development experience.
Key changes include:
- Introduction of a new
/sharedTypeScript directory with utilities moved from/domain - Migration from Docker-based to npm-based test execution in CI pipelines
- Comprehensive Jest configuration refactoring with multi-project setup
Reviewed Changes
Copilot reviewed 31 out of 34 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| shared/ | New TypeScript modules for term handling, semester utilities, and periods |
| webpack.config.js | Added TypeScript support and path aliases for shared/domain imports |
| package.json | Added build scripts for shared code and Jest project configurations |
| jest.*.config.js | Multi-project Jest setup with separate configs for client/server/domain/shared |
| .azure/ | Updated CI pipelines to use npm-based testing instead of Docker |
| build.sh | Improved script reliability with error handling and optional environment parameter |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
0829147 to
1ea68d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 31 out of 34 changed files in this pull request and generated 5 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good job on this Benni! ⭐
For the semesterUtils and other utils files, would it be possible to add some example input and outputs in the function description? Simply done as for
/**
*
* @param kthSemesterString 20241
* @returns ["2024", "1"]
*/
for example. It's tricky to keep the different period, semester and term formats in your head.
Thank you for pointing this out, @allazis , I whole-heartedly agree! This is now addressed in 4881d0e. |
Summary
This PR
/sharedwith ts-code. Some of that code has been copied over from/domainsharedfolder has to be compiled before theserver-folder can run it.formatISODatewhich is not used anymore. The initial reason for removal as part of this PR was that the tests behaved differently in the pipeline (on-agent) compared to on the local machine. (because of time-zones)Jest changes
Testing
Copilot generated summary
This pull request introduces significant improvements to the build, test, and module resolution workflow, refactors scripts for better reliability, and removes unused code. The main changes focus on adopting a TypeScript build step for shared code, updating test configurations to support multi-project Jest setups, and cleaning up module imports and exports for maintainability.
Build and Test Pipeline Modernization
Updated Azure Pipelines configuration to run unit tests using an npm-based template (
npm.yml) instead of the previous Docker Compose setup, specifying Node.js 20 and a shared build step. This streamlines CI and aligns with the new TypeScript build step. (.azure/azure-pipelines.pr.yml, .azure/azure-pipelines.ref.yml) [1] [2] [3]Added a TypeScript build step for the shared codebase (
build:shared), and updatedpackage.jsonscripts to ensure shared code is built before running builds or tests. This improves reliability and developer experience.Multi-Project Jest Configuration
Introduced a base Jest configuration (
jest.base.js) and separate configs for client, server, domain, and shared code, enabling targeted and efficient testing across different parts of the codebase. New scripts allow running tests per project or only on changed files. [1] [2] [3] [4] [5] [6]Added
ts-jestand improved module mapping in test configs to support TypeScript and cross-project imports.Module Resolution and Import Clean-up
Updated TypeScript configuration (
public/tsconfig.json) to support path aliases for shared and domain code, and added project references for incremental builds.Improved ESLint configuration to support webpack-based import resolution, aiding editor integration and code quality.
Updated imports in several files to use new path aliases and shared code, supporting code reuse and maintainability. [1] [2] [3] [4] [5]
Script and Environment Improvements
Refactored
build.shfor better reliability: added strict error handling, made the environment argument optional, and improved conditional logic for build modes. [1] [2] [3] [4]Enhanced
nodemon.jsonto watch additional folders and set environment variables for development.Code and Test Clean-up
formatISODatefunction and its associated tests from thedomain/date.jsmodule, reflecting a move away from legacy date formatting logic. [1] [2]These changes collectively modernize the development workflow, improve build and test reliability, and pave the way for easier maintenance and future enhancements.