Skip to content

Commit

Permalink
fix react component tests
Browse files Browse the repository at this point in the history
  • Loading branch information
williamcotton committed Jan 19, 2025
1 parent 14aca03 commit 598b4f4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
18 changes: 14 additions & 4 deletions search-input-query-react/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "jsdom",
preset: 'ts-jest',
testEnvironment: 'jsdom',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
transform: {
'^.+\\.(ts|tsx)$': ['ts-jest', {
tsconfig: 'tsconfig.json',
useESM: true,
}],
},
moduleNameMapper: {
"\\.(css|less|scss|sass)$": "identity-obj-proxy", // For handling CSS imports
'^(\\.{1,2}/.*)\\.js$': '$1',
},
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"], // Optional setup file
extensionsToTreatAsEsm: ['.ts', '.tsx'],
testRegex: 'src/.*\\.(test|spec)\\.(jsx?|tsx?)$',
setupFilesAfterEnv: ['@testing-library/jest-dom'],
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
};
8 changes: 8 additions & 0 deletions search-input-query-react/src/SearchInputQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const mockMonaco = {
editor: {
defineTheme: jest.fn(),
setThemeData: jest.fn(),
addKeybindingRule: jest.fn(),
},
languages: {
register: jest.fn(),
Expand All @@ -73,8 +74,15 @@ const mockMonaco = {
Value: 3,
},
},
KeyMod: {
CtrlCmd: 2048,
Shift: 1024,
Alt: 512,
WinCtrl: 256
},
KeyCode: {
Enter: 13,
KeyF: 33
},
Range: jest.fn(),
};
Expand Down
13 changes: 7 additions & 6 deletions search-input-query-react/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
"jsx": "react",
"resolveJsonModule": true,
"isolatedModules": true,
"moduleDetection": "force"
"moduleDetection": "force",
"allowJs": true
},
"include": [
"./src/*.ts",
"./src/*.tsx"
"./src/**/*.ts",
"./src/**/*.tsx",
"./src/**/*.test.ts",
"./src/**/*.test.tsx"
],
"exclude": [
"node_modules",
"dist",
"**/*.test.ts",
"jest.config.ts"
"dist"
]
}
2 changes: 2 additions & 0 deletions search-input-query-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"outDir": "./dist/cjs",
"module": "ESNext",
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"noEmit": true
}
}

0 comments on commit 598b4f4

Please sign in to comment.