jest-styled-components icon indicating copy to clipboard operation
jest-styled-components copied to clipboard

tohaveStyleRule not a function!!

Open JamieYoungman-zz opened this issue 6 years ago • 3 comments

Had this issue before, and solved this by downgrading style components. This is working on my other projects but not my new one, despite using the exact same package.json.

I'm really confused so any help i'd much appreciate.

"enzyme": "^3.8.0",
   "enzyme-adapter-react-16": "^1.7.1",
   "eslint-plugin-prettier": "^3.0.1",
   "jest-styled-components": "^6.3.1",
   "prettier": "^1.6.4",
   "react": "^16.6.3",
   "react-dom": "^16.6.3",
   "react-scripts": "2.1.1",
   "react-test-renderer": "^16.6.3",
   "styled-components": "^3.3.2" 
 it('should default to the first slide', () => {
		expect(element.find('SlideWrapper')).toHaveStyleRule(
			'transform',
			'translateX(0px)'
		);
	});

I do have this on a repo if you require. The only thing i could think of is that some caching is happening somewhere but i cleared my node modules and re installed.

Thanks in advance

JamieYoungman-zz avatar Mar 23 '19 21:03 JamieYoungman-zz

I'm running into the same issue right now. Any help on this would be appreciated.

EDIT: Realized I forgot to import 'jest-styled-components'; at the top of my spec file.

goodbomb avatar Mar 29 '19 18:03 goodbomb

In addition to having "jest-styled-components" I also needed "jest-enzyme"

JonathanSpok avatar Nov 13 '19 21:11 JonathanSpok

I'm running into the same issue right now. Any help on this would be appreciated.

EDIT: Realized I forgot to import 'jest-styled-components'; at the top of my spec file.

Thank you bro! The same here. I just did the same and it worked.

tech3br avatar Dec 12 '21 04:12 tech3br