Skip to content

Commit 915a0c2

Browse files
committed
test(resume): Add Jest DOM type definitions and testing configuration
- Add global type definitions for Jest DOM matchers - Update tsconfig.json to include @testing-library/jest-dom types - Modify resume integration tests to include default content structure - Enhance testing infrastructure with comprehensive type support - Improve type checking and testing capabilities for resume components
1 parent 7caf1e6 commit 915a0c2

File tree

4 files changed

+82
-4
lines changed

4 files changed

+82
-4
lines changed

__tests__/resume-integration.test.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,12 @@ describe('Resume Builder Integration Tests', () => {
193193
title: 'Personal Information',
194194
order: 0,
195195
visible: true,
196-
content: {},
196+
content: {
197+
full_name: '',
198+
email: '',
199+
phone: '',
200+
location: '',
201+
},
197202
},
198203
{
199204
id: 'section-2',
@@ -238,7 +243,12 @@ describe('Resume Builder Integration Tests', () => {
238243
title: 'Personal Information',
239244
order: 0,
240245
visible: true,
241-
content: {},
246+
content: {
247+
full_name: '',
248+
email: '',
249+
phone: '',
250+
location: '',
251+
},
242252
},
243253
{
244254
id: 'section-2',

global.d.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/// <reference types="@testing-library/jest-dom" />
2+
3+
import '@testing-library/jest-dom';
4+
5+
declare global {
6+
namespace jest {
7+
interface Matchers<R = void> {
8+
toBeInTheDocument(): R;
9+
toBeVisible(): R;
10+
toBeEmpty(): R;
11+
toBeEmptyDOMElement(): R;
12+
toBeDisabled(): R;
13+
toBeEnabled(): R;
14+
toBeInvalid(): R;
15+
toBeRequired(): R;
16+
toBeValid(): R;
17+
toContainElement(element: HTMLElement | SVGElement | null): R;
18+
toContainHTML(htmlText: string): R;
19+
toHaveAccessibleDescription(expectedAccessibleDescription?: string | RegExp): R;
20+
toHaveAccessibleName(expectedAccessibleName?: string | RegExp): R;
21+
toHaveAttribute(attr: string, value?: unknown): R;
22+
toHaveClass(...classNames: string[]): R;
23+
toHaveFocus(): R;
24+
toHaveFormValues(expectedValues: Record<string, unknown>): R;
25+
toHaveStyle(css: string | Record<string, unknown>): R;
26+
toHaveTextContent(text: string | RegExp, options?: { normalizeWhitespace: boolean }): R;
27+
toHaveValue(value?: string | string[] | number | null): R;
28+
toHaveDisplayValue(value: string | RegExp | Array<string | RegExp>): R;
29+
toBeChecked(): R;
30+
toBePartiallyChecked(): R;
31+
toHaveErrorMessage(text: string | RegExp): R;
32+
}
33+
}
34+
}

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"isolatedModules": true,
1515
"jsx": "preserve",
1616
"incremental": true,
17+
"types": ["@testing-library/jest-dom"],
1718
"plugins": [
1819
{
1920
"name": "next"
@@ -23,6 +24,6 @@
2324
"@/*": ["./*"]
2425
}
2526
},
26-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
27-
"exclude": ["node_modules", "backup-old-cache-files"]
27+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "types/**/*.d.ts"],
28+
"exclude": ["node_modules", "backup-old-cache-files", "**/*.test.ts", "**/*.test.tsx", "__tests__/**/*"]
2829
}

types/jest-dom.d.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/// <reference types="@testing-library/jest-dom" />
2+
3+
import '@testing-library/jest-dom';
4+
import type * as jestGlobals from '@jest/globals';
5+
6+
declare module '@jest/globals' {
7+
interface Matchers<R = void> extends jestGlobals.Matchers<R> {
8+
toBeInTheDocument(): R;
9+
toBeVisible(): R;
10+
toBeEmpty(): R;
11+
toBeEmptyDOMElement(): R;
12+
toBeDisabled(): R;
13+
toBeEnabled(): R;
14+
toBeInvalid(): R;
15+
toBeRequired(): R;
16+
toBeValid(): R;
17+
toContainElement(element: HTMLElement | SVGElement | null): R;
18+
toContainHTML(htmlText: string): R;
19+
toHaveAccessibleDescription(expectedAccessibleDescription?: string | RegExp): R;
20+
toHaveAccessibleName(expectedAccessibleName?: string | RegExp): R;
21+
toHaveAttribute(attr: string, value?: unknown): R;
22+
toHaveClass(...classNames: string[]): R;
23+
toHaveFocus(): R;
24+
toHaveFormValues(expectedValues: Record<string, unknown>): R;
25+
toHaveStyle(css: string | Record<string, unknown>): R;
26+
toHaveTextContent(text: string | RegExp, options?: { normalizeWhitespace: boolean }): R;
27+
toHaveValue(value?: string | string[] | number | null): R;
28+
toHaveDisplayValue(value: string | RegExp | Array<string | RegExp>): R;
29+
toBeChecked(): R;
30+
toBePartiallyChecked(): R;
31+
toHaveErrorMessage(text: string | RegExp): R;
32+
}
33+
}

0 commit comments

Comments
 (0)