Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLIDE: testing #22

Closed
10 of 11 tasks
flexbox opened this issue Dec 6, 2021 · 0 comments
Closed
10 of 11 tasks

SLIDE: testing #22

flexbox opened this issue Dec 6, 2021 · 0 comments
Milestone

Comments

@flexbox
Copy link
Owner

flexbox commented Dec 6, 2021

it("works", () => {
  expect(1).toBe(1);
});
  • on package.json
    "test": "jest",
    "test:unit:watch": "jest --watch",
  • test with yarn test:unit
  • add your first test on src/components/StarshipCard.test.tsx
  • Test if title, cost ... are presents
  • test with yarn test:unit:watch
import React from "react";

import { render } from "testing-library";
import { StarshipCard } from "~/components/StarshipCard";

const shipFixture = {
...
}

describe("StarshipCard", () => {
  it("renders correctly", () => {
    const { getByText, debug } = render(
      <StarshipCard ship={shipFixture} />
    );
    debug() <----- just to test
    getByText("Star Destroyer");
    getByText("150000000 credits");
  });
});

Updating Jest setup

Testing code using React Navigation takes some setup since we need to mock some native dependencies used in the navigators.

@flexbox flexbox added this to the Objectif IUT milestone Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants