Skip to content

Commit

Permalink
chore: Handle absolute imports in Remix example
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyễn Thanh Sơn committed May 8, 2022
1 parent 6865de7 commit 2d7f300
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/remix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ module.exports = {
- // Handle image imports
- // https://jestjs.io/docs/webpack#handling-static-assets
- '^.+\\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i': `<rootDir>/__mocks__/fileMock.js`,
+ // Handle absolute imports in Remix
+ '~/(.*)': '<rootDir>/app/$1',
},
+ setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testPathIgnorePatterns: [
Expand Down
2 changes: 1 addition & 1 deletion examples/remix/app/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import remixImg from '../assets/remix.jpg';
import remixImg from '~/assets/remix.jpg';

export default function Index() {
return (
Expand Down
2 changes: 2 additions & 0 deletions examples/remix/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module.exports = {
'!**/node_modules/**',
],
moduleNameMapper: {
// Handle absolute imports in Remix
'~/(.*)': '<rootDir>/app/$1',
},
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testPathIgnorePatterns: [
Expand Down

0 comments on commit 2d7f300

Please sign in to comment.