-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
configure jest as test framework, and add some test code
- Loading branch information
Showing
11 changed files
with
81 additions
and
17 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
import {cleanup, fireEvent, render, screen} from '../../utils/test/test.utils'; | ||
import Button from './button.component'; | ||
|
||
// Note: running cleanup afterEach is done automatically for you in @testing-library/[email protected] or higher | ||
// unmount and cleanup DOM after the test is finished. | ||
afterEach(cleanup); | ||
|
||
it('button with specific text exit', async () => { | ||
const {getByText} = render( | ||
<Button>TEST</Button>, | ||
); | ||
|
||
expect(await screen.findByText("TEST")).toBeTruthy(); | ||
fireEvent.click(getByText(/test/i)); | ||
|
||
}); |
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
File renamed without changes.
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,34 @@ | ||
// jest.resolver.js | ||
module.exports = (path, options) => { | ||
// Call the defaultResolver, so we leverage its cache, error handling, etc. | ||
return options.defaultResolver(path, { | ||
...options, | ||
// Use packageFilter to process parsed `package.json` before the resolution (see https://www.npmjs.com/package/resolve#resolveid-opts-cb) | ||
packageFilter: (pkg) => { | ||
const pkgNamesToTarget = new Set([ | ||
'rxjs', | ||
'@firebase/auth', | ||
'@firebase/storage', | ||
'@firebase/functions', | ||
'@firebase/database', | ||
'@firebase/auth-compat', | ||
'@firebase/database-compat', | ||
'@firebase/app-compat', | ||
'@firebase/firestore', | ||
'@firebase/firestore-compat', | ||
'@firebase/messaging', | ||
'@firebase/util', | ||
'firebase', | ||
'@stripe/stripe-js', | ||
]); | ||
|
||
if (pkgNamesToTarget.has(pkg.name)) { | ||
// console.log('>>>', pkg.name) | ||
delete pkg['exports']; | ||
delete pkg['module']; | ||
} | ||
|
||
return pkg; | ||
}, | ||
}); | ||
}; |
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,23 @@ | ||
import React, {ReactElement} from 'react'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import {render, RenderOptions} from '@testing-library/react'; | ||
import { store } from '../../store/store'; | ||
import { Provider } from 'react-redux'; | ||
|
||
const AllTheProviders = ({children}: {children: React.ReactNode}) => { | ||
return ( | ||
<BrowserRouter> | ||
<Provider store={store}> | ||
{children} | ||
</Provider> | ||
</BrowserRouter> | ||
) | ||
}; | ||
|
||
const customRender = ( | ||
ui: ReactElement, | ||
options?: Omit<RenderOptions, 'wrapper'>, | ||
) => render(ui, {wrapper: AllTheProviders, ...options}); | ||
|
||
export * from '@testing-library/react'; | ||
export {customRender as render}; |