Skip to content

Commit 3a9568a

Browse files
committed
chore: fix tasks
1 parent c5b9b80 commit 3a9568a

File tree

15 files changed

+35
-17
lines changed

15 files changed

+35
-17
lines changed

apps/shop-e2e/eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default [
55
playwright.configs['flat/recommended'],
66
...baseConfig,
77
{
8-
files: ['**/*.ts', '**/*.js'],
8+
files: ['src/**/*.ts', 'src/**/*.js'],
99
// Override or add rules here
1010
rules: {},
1111
},

apps/shop/tsconfig.spec.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
"@nx/react/typings/cssmodule.d.ts",
1212
"@nx/react/typings/image.d.ts"
1313
],
14+
"lib": ["es2022", "dom"],
1415
"jsx": "react-jsx"
1516
},
1617
"include": [
1718
"vite.config.ts",
1819
"vite.config.mts",
1920
"vitest.config.ts",
2021
"vitest.config.mts",
22+
"src/test-setup.ts",
2123
"src/**/*.test.ts",
2224
"src/**/*.spec.ts",
2325
"src/**/*.test.tsx",

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default [
1010
'**/vite.config.*.timestamp*',
1111
'**/vitest.config.*.timestamp*',
1212
'**/test-output',
13+
'**/out-tsc'
1314
],
1415
},
1516
{

libs/api/products/src/lib/products.service.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { describe, it, expect, beforeEach } from '@jest/globals';
21
import { ProductsService } from './products.service';
32
// eslint-disable-next-line
43
import { ProductFilter } from '@org/models';

libs/shared/test-utils/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
},
1313
"./package.json": "./package.json"
1414
},
15+
"devDependencies": {
16+
"@org/models": "workspace:*"
17+
},
1518
"nx": {
1619
"sourceRoot": "libs/shared/test-utils/src",
1720
"projectType": "library",

libs/shared/test-utils/src/lib/test-render.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ReactElement } from 'react';
2-
import { render, RenderOptions } from '@testing-library/react';
2+
import {render, RenderOptions, RenderResult} from '@testing-library/react';
33
import { BrowserRouter } from 'react-router-dom';
44

55
interface AllTheProvidersProps {
@@ -13,9 +13,9 @@ function AllTheProviders({ children }: AllTheProvidersProps) {
1313
export function renderWithRouter(
1414
ui: ReactElement,
1515
options?: Omit<RenderOptions, 'wrapper'>
16-
) {
16+
): RenderResult {
1717
return render(ui, { wrapper: AllTheProviders, ...options });
1818
}
1919

2020
export * from '@testing-library/react';
21-
export { renderWithRouter as render };
21+
export { renderWithRouter as render };

libs/shop/data/src/lib/hooks/use-product.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function useProduct(id: string | undefined) {
2020

2121
try {
2222
const response = await fetch(`${API_URL}/products/${id}`);
23-
const data: ApiResponse<Product> = await response.json();
23+
const data: ApiResponse<Product> = await response.json() as ApiResponse<Product>;
2424

2525
if (!data.success) {
2626
throw new Error(data.error || 'Failed to load product');
@@ -45,4 +45,4 @@ export function useProduct(id: string | undefined) {
4545
loading,
4646
error,
4747
};
48-
}
48+
}

libs/shop/data/src/lib/hooks/use-products.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { renderHook, waitFor } from '@testing-library/react';
22
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
33
import { useProducts } from './use-products';
4+
import {ProductFilter} from "@org/models";
45

56
// Mock fetch
67
global.fetch = vi.fn();
@@ -169,7 +170,7 @@ describe('useProducts', () => {
169170
const { result, rerender } = renderHook(
170171
({ filter }) => useProducts(filter),
171172
{
172-
initialProps: { filter: undefined },
173+
initialProps: { filter: undefined } as {filter?: ProductFilter},
173174
}
174175
);
175176

@@ -180,7 +181,7 @@ describe('useProducts', () => {
180181
expect(fetch).toHaveBeenCalledTimes(1);
181182

182183
// Change filter
183-
rerender({ filter: { category: 'Electronics' } });
184+
rerender({ filter: { category: 'Electronics' }});
184185

185186
await waitFor(() => {
186187
expect(fetch).toHaveBeenCalledTimes(2);
@@ -223,4 +224,4 @@ describe('useProducts', () => {
223224
'http://localhost:3333/api/products?page=2&pageSize=12'
224225
);
225226
});
226-
});
227+
});

libs/shop/data/src/lib/hooks/use-products.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function useProducts(
3434
}
3535

3636
const response = await fetch(`${API_URL}/products?${params}`);
37-
const data: ApiResponse<PaginatedResponse<Product>> = await response.json();
37+
const data: ApiResponse<PaginatedResponse<Product>> = await response.json() as ApiResponse<PaginatedResponse<Product>>;
3838

3939
if (!data.success) {
4040
throw new Error(data.error || 'Failed to load products');
@@ -79,7 +79,7 @@ export function useCategories() {
7979

8080
try {
8181
const response = await fetch(`${API_URL}/products/categories`);
82-
const data: ApiResponse<string[]> = await response.json();
82+
const data: ApiResponse<string[]> = await response.json() as ApiResponse<string[]>;
8383

8484
if (!data.success) {
8585
throw new Error(data.error || 'Failed to load categories');
@@ -104,4 +104,4 @@ export function useCategories() {
104104
loading,
105105
error,
106106
};
107-
}
107+
}

libs/shop/feature-product-detail/tsconfig.lib.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"@nx/react/typings/cssmodule.d.ts",
88
"@nx/react/typings/image.d.ts"
99
],
10+
"lib": ["es2022", "dom"],
1011
"rootDir": "src",
1112
"jsx": "react-jsx",
1213
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo"

0 commit comments

Comments
 (0)