I'm trying to mock a function which is called inside my react component. Here is an exemple, with the function getContent(). How could I set my own return value in the test ?
Component.test.tsx :
describe('TEST', () => {
it('test', () => {
...
expect.assertions(1);
renderer = render(<MyComponent></MyComponent>)
expect(renderer.toContain('myValue'))
}
)}
MyComponent.tsx :
export const MyComponent = (props) => {
const externalClass = new classFromAnotherFile()
const content = externalClass.getContent()
return (
<View>
content={content}
</View>
}
AnotherFile.tsx
export class classFromAnotherFile {
constructor(...){}
getContent(): string { ... }
}