Skip to content

Commit

Permalink
jest test setup between sample-app components and headless-react top …
Browse files Browse the repository at this point in the history
…level repo
  • Loading branch information
Yen Truong committed Oct 25, 2021
1 parent c0481d0 commit 65c371f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions __mocks__/styleMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
2 changes: 2 additions & 0 deletions __mocks__/svgMock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import * as React from 'react';
module.exports = { ReactComponent: () => <div>IconMock</div> };
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
"testEnvironment": "jsdom",
"testMatch": [
"<rootDir>/tests/**/*.(test).ts(x)?"
]
],
"moduleNameMapper": {
"@yext/answers-headless-react": "<rootDir>/src",
"\\.svg$": "<rootDir>/__mocks__/svgMock.tsx",
"\\.(css|scss)$": "<rootDir>/__mocks__/styleMock.ts"
}
}
}
10 changes: 10 additions & 0 deletions react-app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
declare module '*.svg' {
import * as React from 'react';

export const ReactComponent: React.FunctionComponent<React.SVGProps<
SVGSVGElement
> & { title?: string }>;

const src: string;
export default src;
}
8 changes: 4 additions & 4 deletions sample-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"jsx": "react-jsx"
},
"include": [
"src"
"src",
"react-app.d.ts"
]
}

0 comments on commit 65c371f

Please sign in to comment.