-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(configs): improve Jest config for TypeScript (#580)
* test(configs): fix Jest config for TypeScript feature/typescript-jest feature/typescript-jest * docs: update test command feature/typescript-jest
- Loading branch information
1 parent
477568d
commit 301414d
Showing
11 changed files
with
142 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/*.story.* | ||
**/*.spec.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,7 @@ yarn lint:fix | |
## Testing | ||
|
||
``` | ||
yarn test:watch | ||
yarn test | ||
``` | ||
|
||
```javascript | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* Copyright 2020, SumUp Ltd. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import React, { FunctionComponent } from 'react'; | ||
import { renderToStaticMarkup } from 'react-dom/server'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { axe } from 'jest-axe'; | ||
import { render as renderTest, wait, act } from '@testing-library/react'; | ||
import { renderHook, act as actHook } from '@testing-library/react-hooks'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { ThemeProvider } from 'emotion-theming'; | ||
import { light } from '@sumup/design-tokens'; | ||
|
||
import ComponentsContext, { | ||
defaultComponents | ||
} from '../components/ComponentsContext'; | ||
|
||
export type RenderFn = (component: React.ReactElement, ...rest: any) => any; | ||
|
||
const WithProviders: FunctionComponent = ({ children }) => ( | ||
<ComponentsContext.Provider value={defaultComponents}> | ||
<ThemeProvider theme={light}>{children}</ThemeProvider> | ||
</ComponentsContext.Provider> | ||
); | ||
|
||
const renderWithProviders = (renderer: RenderFn): RenderFn => ( | ||
component, | ||
...rest | ||
): RenderFn => renderer(<WithProviders>{component}</WithProviders>, rest); | ||
|
||
const render: RenderFn = (component, options) => | ||
renderTest(component, { wrapper: WithProviders, ...options }); | ||
const renderToHtml: RenderFn = renderWithProviders(renderToStaticMarkup); | ||
const create: RenderFn = (...args) => { | ||
const { container } = render(...args); | ||
return container.children.length > 1 | ||
? container.children | ||
: container.firstChild; | ||
}; | ||
|
||
export { | ||
create, | ||
render, | ||
renderToHtml, | ||
renderHook, | ||
act, | ||
actHook, | ||
userEvent, | ||
wait, | ||
axe | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters