From c248734d34d4d849e6ddc6e48d34e82c59404ced Mon Sep 17 00:00:00 2001 From: Kevin Brewer Date: Sat, 23 Mar 2019 08:54:10 -0700 Subject: [PATCH] chore(docs): tweak unit testing to remove invalid props from Link (#12445) ## Description I followed the Unit-Testing docs to set up jest with Gatsby, and I ran into the following error related to Gatsby's `Link` component: ``` React does not recognize the `activeStyle` prop on a DOM element. ``` ## Changes Removing the `activeStyle` prop from the `Link` mock fixed the issue for me. Seems like this should be the default setup. I was unable to find any discussion of this issue on the internet, sorry if there's something I'm missing. --- docs/docs/unit-testing.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/docs/unit-testing.md b/docs/docs/unit-testing.md index 4bda866814d74..533cc55632cb4 100644 --- a/docs/docs/unit-testing.md +++ b/docs/docs/unit-testing.md @@ -132,11 +132,22 @@ const gatsby = jest.requireActual("gatsby") module.exports = { ...gatsby, graphql: jest.fn(), - Link: jest.fn().mockImplementation(({ to, ...rest }) => - React.createElement("a", { - ...rest, - href: to, - }) + Link: jest.fn().mockImplementation( + // these props are invalid for an `a` tag + ({ + activeClassName, + activeStyle, + getProps, + innerRef, + ref, + replace, + to, + ...rest + }) => + React.createElement("a", { + ...rest, + href: to, + }) ), StaticQuery: jest.fn(), useStaticQuery: jest.fn(),