...

/

Checking for null and undefined

Checking for null and undefined

Learn about checking for results that are “null” and “undefined” or not “null” or not “undefined."

Checking for null

The project for this lesson contains two functions, getPerson and getCompany, that are being tested. A copy of the project’s code is in the code widget below:

import { getCompany } from "./data";

test("Should return correct company object when found", async () => {
  const company = await getCompany(1);
  expect(company.name).toBe("Dibbert Group");
});
Starter project

At the moment, only the happy path is being tested. The cases when the person or company is not found are not covered at the moment.

Let’s focus on the unhappy path test for getPerson. In data.getPerson.test.js, Implement this test using a ...

Access this course and 1400+ top-rated courses and projects.