Skip to content

Commit

Permalink
chore(docs): tweak unit testing to remove invalid props from Link (ga…
Browse files Browse the repository at this point in the history
…tsbyjs#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.
  • Loading branch information
appleJax authored and DSchau committed Mar 23, 2019
1 parent b911e8d commit c248734
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions docs/docs/unit-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit c248734

Please sign in to comment.