-
Notifications
You must be signed in to change notification settings - Fork 5
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
refactor: added absolute import paths to unit tests #215
Conversation
…organization and testing The import paths have been updated to use the "@" alias for better readability and to avoid relative path issues. This change improves code organization and makes it easier to navigate through the codebase. The Jest configuration has also been updated to reflect these changes and ensure that the tests run correctly with the new import paths. The root directory for Jest has been changed to the project root, and a new moduleDirectories property has been added to include "src" along with "node_modules". This allows Jest to resolve modules from the "src" directory as well as "node_modules". The moduleNameMapper has been updated to map "@" to "src", which aligns with the updated import paths. The testRegex has been changed to ".spec.ts$" to match the naming convention of the test files. In addition, the tsconfig.json file has been updated to reflect the changes in the import paths. The "@shared/*" path has been removed as it is no longer needed. These changes improve the overall structure and organization of the codebase, making it easier to maintain and test.
…ameMapper for better path resolution refactor(package.json): update testRegex to include int-spec.ts files for more comprehensive testing refactor(health-check.controller.ts): update import path to use alias for better readability feat(health-check.service.int-spec.ts): add ConfigModule and DB-Config provider for more flexible testing setup refactor(health-check.service.int-spec.ts): add afterAll block to clean up database after tests The rootDir and moduleNameMapper changes in package.json improve path resolution, making it easier to manage and understand the project structure. The testRegex update allows Jest to recognize and run integration tests, enhancing the test coverage. The import path in health-check.controller.ts is updated to use an alias, improving readability and maintainability. The health-check.service.int-spec.ts file now imports ConfigModule and provides a DB-Config, making the testing setup more flexible and adaptable to different environments. An afterAll block is added to clean up the database after tests, ensuring a clean state for each test run.
…ute import paths The change was made to improve the readability and maintainability of the unit tests. Using absolute import paths makes the code cleaner and easier to understand, as it eliminates the need for complex relative paths. This change aligns with the previous refactoring of e2e tests to use absolute import paths.
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.
…s for better project structure feat(package.json, tsconfig.json): add @prisma alias for prisma directory The rootDir in package.json is changed from 'src' to '.' to better reflect the project structure. The module paths are adjusted accordingly. This change makes the project structure more intuitive and easier to navigate. Additionally, a new alias '@prisma' is added for the prisma directory, which simplifies the import statements and makes the code cleaner.
…bility and maintainability The import paths in the auth module, auth service, auth service spec, and discord auth service have been updated to use the '@' alias instead of relative paths. This change improves readability and maintainability of the code by making it easier to understand the file structure and to update import paths when files are moved or renamed.
…e relative paths with absolute paths for better readability and maintainability The import statements in the development.service.spec.ts and development.service.ts files have been refactored to use absolute paths instead of relative paths. This makes the code more readable and easier to maintain, as it's clear where the imported modules are located in the project structure.
…for better readability and maintainability The import paths in the features.controller.ts and features.service.ts files have been changed from relative paths to alias paths. This makes the code more readable and easier to maintain, as it reduces the complexity of the paths and makes it easier to understand the structure of the project.
…er readability and maintainability The relative imports in the forms.controller.ts and forms.service.ts files have been replaced with absolute imports. This change improves the readability of the code and makes it easier to maintain, as it is now clear where the imported modules are located in the project structure.
…ility and maintainability The import paths have been updated to use absolute paths instead of relative paths. This makes the code more readable and easier to maintain, as it's clear where the imported modules are located in the project structure. It also reduces the risk of errors when moving files around within the project.
The import path for PrismaService has been updated to use an absolute path instead of a relative one. This change improves code readability and maintainability by making it easier to understand where the imported modules are located in the project structure.
…better readability and maintainability The relative imports in the ideations.controller.ts and ideations.service.ts files have been replaced with absolute imports. This change improves readability and maintainability by making it easier to understand where the imported modules are located in the project structure. It also reduces the risk of errors when moving files around, as the absolute import paths remain valid regardless of the file's location.
…quest The import paths for FormResponseDto and CustomRequest have been updated to use absolute paths instead of relative paths. This change improves code readability and maintainability by making it easier to understand where the imported modules are located in the project structure.
…rt path for DbConfig The import path for DbConfig has been changed from a relative path to an alias path. This change improves code readability and maintainability by making the import paths more consistent and easier to manage.
… imports with absolute imports for better readability and maintainability The relative imports in resources.module.ts and resources.service.ts have been replaced with absolute imports. This change improves the readability of the code and makes it easier to maintain, as it's now clear where the imported modules are located in the project structure.
… better maintainability The relative import paths in the sprints module, controller, service, and response files have been changed to absolute paths. This makes the code more maintainable and easier to navigate, as it is now clear where the imported modules are located in the project structure.
The import path for PrismaService was incorrect, causing the application to fail when trying to import it. The path has been corrected to "@/prisma/prisma.service", ensuring that the application can now correctly import and use PrismaService.
…er readability and maintainability The relative imports in the teams module have been replaced with absolute imports. This change improves the readability of the code and makes it easier to maintain, as it is now clear where the imported modules are located in the project structure.
…hs with absolute paths for better maintainability The relative paths in techs.controller.ts and techs.service.ts have been replaced with absolute paths. This change makes the code easier to maintain and understand, as it is now clear where the imported modules are located in the project structure. It also reduces the risk of errors when moving files around, as the absolute paths remain valid regardless of the location of the file that imports them.
…r readability and maintainability The relative paths in the users module have been replaced with absolute paths. This change improves the readability of the code and makes it easier to maintain, as it's now clear where the imported modules are located in the project structure.
… and AppConfigService The import paths for MailConfigService and AppConfigService have been updated to use absolute paths instead of relative paths. This change improves code readability and maintainability by making it easier to understand where the imported modules are located in the project structure.
…er readability and maintainability The import paths in the voyages.controller.ts and voyages.service.ts files have been updated to use absolute paths instead of relative paths. This makes the code more readable and easier to maintain, as it's clear where the imported modules are located in the project structure.
…ter test coverage The Prisma directory is now included in the moduleNameMapper configuration in jest-e2e.json. This allows Jest to resolve modules from the Prisma directory, improving the test coverage for Prisma-related code.
… paths The import paths in all test files have been updated to use the "@" alias instead of relative paths. This change improves readability and maintainability of the code. It also makes it easier to move files around in the project structure without having to update every single import statement.
…ter project structure and testing The moduleNameMapper for @prisma has been updated to point to the correct directory, improving the project structure and ensuring that imports from @prisma are correctly resolved. The testRegex has been changed to match both .spec and .jest.ts files, allowing for a wider range of test files to be recognized and executed by Jest.
…with absolute paths for better readability and maintainability The changes were made to replace relative paths with absolute paths. This makes the code more readable and easier to maintain, as it's easier to understand where the imported modules are coming from. It also reduces the risk of errors when files are moved around in the project structure.
I went back to the how the old testregex was to fix how the units command was running the e2e tests after the unit tests. Also I corrected the absolute path in the jest section in the package.json. |
Updated reviewer to @JoshuaHinman |
…ath resolution The baseUrl in tsconfig.json has been changed from "./" to ".". This change was made to improve path resolution and to avoid potential issues with module resolution in different environments.
…s/register The prisma seed script has been updated to include tsconfig-paths/register. This change ensures that TypeScript paths are correctly resolved when running the seed script, preventing potential path resolution errors.
ok, I fixed it by installing |
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.
Everything works fine (tests, seed), whats the difference between @/prisma
and @Prisma
? looks like we need to use @Prisma
in e2e tests
I opted for distinct absolute import paths for the prisma directories to avoid potential conflicts when importing from |
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.
All tests passed and health check table is empty - looks good!
Description
This Pull Request includes refactoring changes to update import paths and Jest configuration for unit tests. The changes improve the overall structure of the codebase, making it easier to maintain and test.
Key changes include:
package.json
to align with the new import paths and improve test executiontsconfig.json
to reflect changes in import pathsThese changes enhance code organization, improve navigation through the codebase, and ensure proper test execution with new structure.
Issue link
Fixes # 86b2346xp
Type of change
How Has This Been Tested?
Verify that the changes work by:
yarn test
oryarn test:docker
(if you use docker)afterall()
in the healthcheck test by runningyarn studio:test
and see that healthcheck table is emptyChecklist: