Open balibou opened 1 year ago
Who error?
I also cannot get this working...
consistently get a variation of this error:
β Test suite failed to run
Cannot create styled-component for component: undefined.
4 | import "jest-styled-components";
5 |
> 6 | const Card = styled.View`
| ^
7 | display: flex;
8 | `;
9 |
Super basic setup:
import { render, screen } from "@src/test-utils/test-utils";
import styled from "styled-components/native";
import "jest-styled-components";
const Card = styled.View`
display: flex;
`;
describe("Card", () => {
it("should render", () => {
const tree = render(<Card />).toJSON();
expect(tree).toMatchSnapshot();
});
});
I also cannot get this working...
consistently get a variation of this error:
β Test suite failed to run Cannot create styled-component for component: undefined. 4 | import "jest-styled-components"; 5 | > 6 | const Card = styled.View` | ^ 7 | display: flex; 8 | `; 9 |
Super basic setup:
import { render, screen } from "@src/test-utils/test-utils"; import styled from "styled-components/native"; import "jest-styled-components"; const Card = styled.View` display: flex; `; describe("Card", () => { it("should render", () => { const tree = render(<Card />).toJSON(); expect(tree).toMatchSnapshot(); }); });
Try to use this structure with the styled component exported from a variable
import * as styledComponents from "styled-components/native";
import * as theme from "./theme";
import * as themeConstants from "./themeConstants";
import * as darkTheme from "./darkTheme";
export { theme };
export { darkTheme };
export { theme as standard };
export { themeConstants };
const { default: styled, css, ThemeProvider } = styledComponents;
export { css, ThemeProvider };
export default styled;
I'm trying to use this library with @testing-library/react and can't make it work properly. I changed package versions, looked on other github repositories and impossible to find a working example. (Does anyone has a working repo to show ?)
package.json
test file
snapshot:
jest.config.js
cssTransform.js