gluestack

gluestack Logogluestack

Testing with Jest

gsfzamai posted this in #support
Open in Discord
Avatar
gsfzamaiOP
Hi there, hope you're fine.
I'm trying to implement some testes with Jest and I'm struggling to mock the components renders
I'm mocking the library like this:
jest.mock('@gluestack-ui/themed', () => {
return {
useStyled: jest.fn(() => ({
config: {
...mockedConfig,
},
})),
Icon: jest.fn(),
Button: jest.fn(),
styled: jest.fn((component, theme, config) => component),
};
});

I need help on how to mock the components. Because when I'm using the render method from RNTL, all Gluestack Components gives me the error below:
    Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

When I use React Native's components, the tests runs as expected

1 Reply