-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Enzyme Internal Error: Enzyme expects an adapter to be configured, but found none. #131
Comments
Hey there, so it didn't work for me as well. So I run import * as enzyme from 'enzyme';
import * as Adapter from 'enzyme-adapter-react-16';
enzyme.configure({ adapter: new Adapter() }); and then // package.json
"jest": {
// ...
"setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js"
} |
I ran into this as well while trying to get started with React. When running |
If it's just a tutorial when I don't see why you should be scared to eject? It's not like you'll need update your tutorial. But didn't thought about adding it in same file. Still would be a bit tedious to add it everywhere you write test. |
Sorry, I’m just too new to the land of npm. I have no idea what eject does, but the warnings it throws up before confirming had me convinced I shouldn’t. I definitely agree that having to do that for every test file in a large app would get old. |
Eject is not is just react specific, all it does is spits out the configuration which create-react-app uses so you won't get updates from cra but you can customize it the way you won't. |
@catchin I follow your pr to add The error message is the same as
|
Why did I get an error in setupTests.js, i have executed
invalid code: Package.json
|
Documenting how to use enzyme with react 16. Fixes #131.
Did anyone manage to follow the react tutorial without ejecting lately? For me, substituting this line
with these lines
in a test file directly does work. Putting those three lines in It's a frustrating experience, trying to boost your productivity with TypeScript and immediately getting stuck with the very first and the very basic tutorial, that's supposed to be polished. Here's my
here's my
and here's
|
This prevents the error |
Following the documentation of this tutorial the Hello.test.tsx files errors like the title above.
From what I read online, the packages
@types/enzyme
andreact-addons-test-utils
would suffice the need to configure an adapter manually on a testsSetup.jsThat didn't work.
I took the second route and wrote a testsSetup.js inside my
src
setupTests.js (should this be
.ts
,.tsx
?, either way it did not work)Hello.test.tsx
Package.json
Another source suggested adding extra config to jest on package.json such as
However that errors as:
Further...
A fresh clone of this repo errors out not running any test suites and complaining about cheerio names.
How can we get the Enzyme Adapter to work with the current project setup on
.tsx
files?The text was updated successfully, but these errors were encountered: