-
Notifications
You must be signed in to change notification settings - Fork 6.8k
test: add utility tests and fix advanced search handling #2615
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
Open
samuelcney
wants to merge
4
commits into
evolution-foundation:main
Choose a base branch
from
samuelcney:feat/improve-coverage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+12,908
−6,571
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
915c203
feat: implement Jest testing framework and add unit tests for excepti…
samuelcney 201f7b9
fix(utils): handle extra spaces and empty queries in advanced operato…
samuelcney 2b5d4cd
test: add unit tests for BadRequestException, advancedOperatorsSearch…
samuelcney 538aaa9
test: add unit tests for getConversationMessage, fetchLatestWaWebVers…
samuelcney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /** | ||
| * Jest configuration for Evolution API test suite. | ||
| * Uses ts-jest to handle TypeScript files and moduleNameMapper | ||
| * to resolve path aliases defined in tsconfig.json. | ||
| */ | ||
|
|
||
| import type { Config } from 'jest'; | ||
|
|
||
| const config: Config = { | ||
| // Use ts-jest preset for TypeScript support | ||
| preset: 'ts-jest', | ||
|
|
||
| // Node environment (no DOM needed for API tests) | ||
| testEnvironment: 'node', | ||
|
|
||
| // Automatically clear mock calls and instances before every test | ||
| clearMocks: true, | ||
|
|
||
| // Collect coverage information | ||
| collectCoverage: true, | ||
|
|
||
| // Coverage output directory | ||
| coverageDirectory: 'coverage', | ||
|
|
||
| // Coverage provider | ||
| coverageProvider: 'v8', | ||
|
|
||
| // Only collect coverage from source files (not test files or node_modules) | ||
| collectCoverageFrom: [ | ||
| 'src/**/*.ts', | ||
| '!src/**/*.d.ts', | ||
| '!src/main.ts', | ||
| ], | ||
|
|
||
| // Map TypeScript path aliases to actual paths (mirrors tsconfig.json paths) | ||
| moduleNameMapper: { | ||
| '^@api/(.*)$': '<rootDir>/src/api/$1', | ||
| '^@cache/(.*)$': '<rootDir>/src/cache/$1', | ||
| '^@config/(.*)$': '<rootDir>/src/config/$1', | ||
| '^@exceptions$': '<rootDir>/src/exceptions', | ||
| '^@libs/(.*)$': '<rootDir>/src/libs/$1', | ||
| '^@utils/(.*)$': '<rootDir>/src/utils/$1', | ||
| '^@validate/(.*)$': '<rootDir>/src/validate/$1', | ||
| }, | ||
|
|
||
| // ts-jest configuration | ||
| transform: { | ||
| '^.+\\.tsx?$': [ | ||
| 'ts-jest', | ||
| { | ||
| tsconfig: { | ||
| // Relax strict mode for tests | ||
| strict: false, | ||
| strictNullChecks: false, | ||
| esModuleInterop: true, | ||
| // Point rootDir to project root so test files are included | ||
| rootDir: './', | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
|
|
||
| // Test file patterns | ||
| testMatch: ['**/test/**/*.test.ts', '**/*.test.ts'], | ||
|
|
||
| // Directories to ignore | ||
| testPathIgnorePatterns: ['/node_modules/', '/dist/'], | ||
|
|
||
| // Verbose output | ||
| verbose: true, | ||
| }; | ||
|
|
||
| export default config; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
suggestion: Consider pointing ts-jest at the existing tsconfig instead of an inline override.
The custom tsconfig block here (e.g., strict: false, rootDir: './') can drift from tsconfig.json and cause tests to compile differently from the app. Prefer using ts-jest’s
tsconfigoption to point at the main tsconfig (or a dedicated test tsconfig) so the configuration stays consistent and easier to maintain.Suggested implementation:
tsconfig.test.json), update thetsconfigpath accordingly:tsconfig: '<rootDir>/tsconfig.test.json'.ts-jestis correctly set up in the rest ofjest.config.ts(e.g.,preset: 'ts-jest'if you are using the preset); adjust as needed to match existing project conventions.