snapshot testing unexpected token

Asked by At

I'm trying to use snapshot testing error

import React from "react";
import LandingPage from "../components/landingpage/LandingPage";


describe("the Landing page should not change", () => {
  it("Landing page matches the snapshot", () => {
    const tree = renderer.create(<LandingPage />).toJSON();

    expect(tree).toMatchSnapshot();
  });
});

But when I try to run jest I get this error

SyntaxError: C:\Users\ryan1\Downloads\Capstone\Ovals\src\unitTesting\snapshot.test.js: Unexpected token (17:33)

  15 | describe("the Landing page should not change", () => {
  16 |   it("Landing page matches the snapshot", () => {
> 17 |     const tree = renderer.create(<LandingPage />).toJSON();
     |                                  ^
  18 | 
  19 |     expect(tree).toMatchSnapshot();
  20 |   });

Does anyone know whats wrong and how to fix it?

0 Answers