-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add tests (rtl + maestro) (#107)
* chore: add tests (rtl + maestro) * ci: add github action
- Loading branch information
1 parent
502d873
commit d1127d6
Showing
22 changed files
with
1,686 additions
and
179 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
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,13 @@ | ||
name: Tests | ||
|
||
on: push | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install modules | ||
run: yarn | ||
- name: Run tests | ||
run: yarn jest |
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 |
---|---|---|
@@ -1 +1 @@ | ||
yarn translate && git diff --exit-code src/locales && yarn lint | ||
yarn translate && git diff --exit-code src/locales && yarn lint && yarn test:coverage --forceExit |
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,8 @@ | ||
const Link = ({ children }: { children: React.ReactNode }) => { | ||
return <>{children}</>; | ||
}; | ||
|
||
const useNavigation = jest.fn().mockReturnValue({ setOptions: jest.fn() }); | ||
const useLocalSearchParams = jest.fn().mockReturnValue({ id: '1' }); | ||
|
||
export { Link, useNavigation, useLocalSearchParams }; |
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,20 @@ | ||
import Movie from 'app/movie/[id]'; | ||
|
||
import { MOCK_MOVIE } from 'api/__mocks__/movie'; | ||
|
||
import * as movie from '../src/api/movie'; | ||
import { render, screen } from '../tests/render'; | ||
|
||
describe('<Movie />', () => { | ||
test('Text renders correctly on HomeScreen', () => { | ||
jest | ||
.spyOn(movie, 'useGetMovie') | ||
.mockReturnValue(MOCK_MOVIE as movie.UseMovie); | ||
|
||
render(<Movie />); | ||
|
||
const textLabel = screen.getByTestId('release-date'); | ||
|
||
expect(textLabel).toHaveTextContent('June 20, 2024'); | ||
}); | ||
}); |
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,13 @@ | ||
{ | ||
"preset": "jest-expo", | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"src/**/*.{ts,tsx,js,jsx}", | ||
"!**/coverage/**", | ||
"!**/node_modules/**", | ||
"!**/babel.config.js", | ||
"!**/expo-env.d.ts", | ||
"!**/.expo/**" | ||
], | ||
"setupFilesAfterEnv": ["./tests/setup.tsx"] | ||
} |
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,7 @@ | ||
appId: com.theomesnil.WhatToWatch | ||
--- | ||
- launchApp | ||
- waitForAnimationToEnd: | ||
timeout: 5000 | ||
- assertVisible: 'Top 10 series' | ||
- takeScreenshot: 'maestro/screenshots/Home' |
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,7 @@ | ||
appId: com.theomesnil.WhatToWatch | ||
--- | ||
- launchApp | ||
- tapOn: 'Search, tab, 2 of 3' | ||
- waitForAnimationToEnd: | ||
timeout: 5000 | ||
- takeScreenshot: 'maestro/screenshots/Search' |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,20 @@ | ||
import { NETWORK_NETFLIX_ID } from 'constants/networks'; | ||
import type { NetworkId } from 'types/content'; | ||
|
||
export const MOCK_MOVIE = { | ||
data: { | ||
coverUrl: '/lgkPzcOSnTvjeMnuFzozRO5HHw1.jpg', | ||
genres: 'Animation - Family', | ||
networkLink: { | ||
id: NETWORK_NETFLIX_ID as NetworkId, | ||
link: 'link' | ||
}, | ||
overview: | ||
'Gru and Lucy and their girls—Margo, Edith and Agnes—welcome a new member to the Gru family, Gru Jr., who is intent on tormenting his dad. Gru also faces a new nemesis in Maxime Le Mal and his femme fatale girlfriend Valentina, forcing the family to go on the run.', | ||
rating: { count: 840, votes: 7.4 }, | ||
releaseDate: '2024-06-20', | ||
runtime: 94, | ||
tagline: 'Things just got a little more despicable.', | ||
title: 'Despicable Me 4' | ||
} | ||
}; |
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,25 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { render } from '@testing-library/react-native'; | ||
import { IntlMessages } from 'locales'; | ||
import * as React from 'react'; | ||
|
||
type AllTheProvidersProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const AllTheProviders = ({ children }: AllTheProvidersProps) => { | ||
const queryClient = new QueryClient(); | ||
|
||
return ( | ||
<IntlMessages> | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
</IntlMessages> | ||
); | ||
}; | ||
|
||
const customRender = (ui: React.ReactElement, options?: unknown[]) => | ||
render(ui, { wrapper: AllTheProviders, ...options }); | ||
|
||
export * from '@testing-library/react-native'; | ||
|
||
export { customRender as render }; |
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,19 @@ | ||
import '@testing-library/react-native/extend-expect'; | ||
|
||
jest.useFakeTimers(); | ||
|
||
jest.mock('expo-localization', () => ({ | ||
getLocales: () => [ | ||
{ | ||
languageCode: 'en', | ||
regionCode: 'EN' | ||
} | ||
] | ||
})); | ||
|
||
jest.mock('react-native-safe-area-context', () => ({ | ||
useSafeAreaInsets: () => ({ | ||
top: 0, | ||
bottom: 0 | ||
}) | ||
})); |
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
Oops, something went wrong.