archfz/cypress-terminal-report

ReferenceError: Cypress is not defined

nkov opened this issue · 11 comments

nkov commented

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)

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

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.

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.

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

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

@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.

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

Released in 1.4.1.

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.

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

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