Closed mosheKerbel closed 3 years ago
Same problem here
import React from "react";
import { mount } from "@cypress/react";
import App from "./App";
it("renders learn react link", () => {
mount(<App />);
cy.get("a").contains("Learn React");
cy.get("img").should("have.class", "App-logo");
});
ERROR in
src/App.test.js
Line 18:3: 'cy' is not defined no-undef
Line 19:3: 'cy' is not defined no-undef
I solved the issue in this way:
Add the ESlint plugin
yarn add -D eslint-plugin-cypress
Then in the package.json
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest",
# add this line
"plugin:cypress/recommended"
]
},
Sorry guys, I just saw this - been swamped with issues in the main Cypress repo. Going over this template now and making sure everything is up to date.
I cannot reproduce this. I deleted my repo, recloned it, did yarn install
and yarn cypress open-ct
. Don't run yarn test app.spec
. That will run Jest, which also comes with Create React App, trying to execute Cypress outside of Cypress (so no global cy
is available. Can you please try running yarn cypress open-ct
? Make sure you clone the latest version to have the latest dependencies - we did a patch since the initial release.
When running yarn cypress open-ct
, everything seems okay. What command are you guys running? Can someone maybe create a bash script with the exact things they ran to reproduce the problem?
Here's what I see:
I think, in my case the problem was renaming the .spec.tsx to .spec.js. If I keep the .tsx everything works.
So if I rename from tsx to jsx I can reproduce? I'll give that a go - all extensions should be supported.
I tried only the .spec files.
Following the blog post tutoruial or clonning the repository results with the same error:
Steps to reproduce: