samedi 3 avril 2021

Why Jest failed on reading imported fonts on react native?

I was trying to do a simple react native test like this:

import React from "react";
import { render } from "@testing-library/react-native";
import { Home } from "../src/screen";

test("Render Home properly", () => {
  const { debug } = render(<Home />);
  debug();
});

but when I run yarn run test, I got following result: Jest Failed Reading Imported Fonts

and my fonts/index.ts looks like this:

import QuicksandBold from "./Quicksand-Bold.ttf";
import QuicksandLight from "./Quicksand-Light.ttf";
import QuicksandMedium from "./Quicksand-Medium.ttf";
import QuicksandRegular from "./Quicksand-Regular.ttf";

export { QuicksandRegular, QuicksandMedium, QuicksandLight, QuicksandBold };

I'm just using basic jest config in my package.json:

"jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  }

Is there any kind of config that I've missed? I just wanna have a pass result on this one. Thank you.

Aucun commentaire:

Enregistrer un commentaire