Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: Cypress is not defined #34

Closed
nkov opened this issue Jun 10, 2020 · 11 comments
Closed

ReferenceError: Cypress is not defined #34

nkov opened this issue Jun 10, 2020 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@nkov
Copy link

nkov commented Jun 10, 2020

I tried adding this plugin to my Cypress project after discovering console.log did not print as expected, following the instructions in the README on latest version of Cypress (4.8.0), and I get this error when trying to run tests:

We invoked the function exported by `/root/project/web-integration-tests/cypress/plugins/index.js`, but it threw an error.

 ReferenceError: Cypress is not defined
    at collectBrowserConsoleLogs (/root/project/web-integration-tests/node_modules/cypress-terminal-report/src/installLogsCollector.js:147:3)
    at installLogsCollector (/root/project/web-integration-tests/node_modules/cypress-terminal-report/src/installLogsCollector.js:45:3)
    at module.exports (/root/project/web-integration-tests/cypress/plugins/index.js:25:62)
    at /root/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:75:12
    at tryCatcher (/root/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/root/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
    at load (/root/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:72:7)
    at EventEmitter.<anonymous> (/root/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:196:5)
    at EventEmitter.emit (events.js:210:5)
    at process.<anonymous> (/root/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/lib/plugins/util.js:25:29)
    at process.emit (events.js:210:5)
    at emit (internal/child_process.js:876:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
@archfz
Copy link
Owner

archfz commented Jun 10, 2020

This is the second issue with 4.8 cypress so it most likely is not compatible with current version.

@archfz archfz added the bug Something isn't working label Jun 10, 2020
@archfz archfz self-assigned this Jun 14, 2020
@archfz
Copy link
Owner

archfz commented Jun 14, 2020

Released in 1.4.0. I could not reproduce this exact issue and it worked with the current changes on 1.4.0. Please feel free to provide more details if this still reproduces.

@archfz archfz closed this as completed Jun 14, 2020
@zentby
Copy link
Contributor

zentby commented Jun 15, 2020

Caught the same error on my side too. I use webpack + cypress, upgraded both (1.2.1 => 1.4.0 and 4.6 => 4.8) before it's failing.
Meant to verify the #32 but got this error when running cypress.

@archfz
Copy link
Owner

archfz commented Jun 15, 2020

The testing in this repo was updated to cypress 4.8 and it works just fine. I'd need more details to debug this.

The way the plugin is installed changed a bit, can you check the readme and make the modifications, maybe that helps. Also you could check how the plugin is installed in this repo on the test/cypress

@archfz archfz reopened this Jun 15, 2020
@archfz
Copy link
Owner

archfz commented Jun 15, 2020

I wonder if this is also related to webpack as well :-?

@zentby
Copy link
Contributor

zentby commented Jun 15, 2020

@archfz I just checked the test and found it's the Readme.md's problem. The plugin path and the support path is opposite in that file.

After switched it, problem solved.

@Morriz
Copy link

Morriz commented Jun 15, 2020

Yeah, switch collector to start in support, and printer in plugins.

@archfz
Copy link
Owner

archfz commented Jun 16, 2020

Released in 1.4.1.

@archfz archfz closed this as completed Jun 16, 2020
@torquedrop
Copy link

I have same error with cypress.

versions:

    "@cypress/react": "^6.0.0",
    "@cypress/webpack-dev-server": "^2.0.0",
    "autoprefixer": "^9",
    "cypress": "^10.3.1",

and this is my test code

import { mount } from '@cypress/react';
import App from './App';

it('renders main react link', () => {
  mount(<App />);
  cy.get('h2').contains('Adding Two Numbers');
});

command: yarn test.

This is output

FAIL  src/App.test.tsx
  ● Test suite failed to run

    ReferenceError: Cypress is not defined

    > 1 | import { mount } from '@cypress/react';
        | ^
      2 | import App from './App';
      3 |
      4 | it('renders main react link', () => {

      at setupHooks (node_modules/@cypress/react/dist/cypress-react.cjs.js:232:5)
      at Object.<anonymous> (node_modules/@cypress/react/dist/cypress-react.cjs.js:429:1)
      at Object.<anonymous> (src/App.test.tsx:1:1)
      at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)
      at runJest (node_modules/@jest/core/build/runJest.js:404:19)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.828 s
Ran all test suites.

Please give me a hand.

@archfz
Copy link
Owner

archfz commented Jul 23, 2022

@DevLancertest do you even use the cypress terminal report plugin?

@torquedrop
Copy link

Thanks @archfz
It's runs correctly. I reinstalled all modules and it runs correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants