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

Uncaught TypeError: Cannot read property 'apply' of undefined #5499

Closed
Versifiction opened this issue Oct 28, 2019 · 4 comments
Closed

Uncaught TypeError: Cannot read property 'apply' of undefined #5499

Versifiction opened this issue Oct 28, 2019 · 4 comments

Comments

@Versifiction
Copy link

Versifiction commented Oct 28, 2019

I have the error below when I want to do some tests, it's because Redux but I can't disabled or turn off the uncaught exception

You can fork https://github.com/Versifiction/ofilms or clone the repo -> npm install -> npm start

I tried with the version 3.4.1 of Cypress and Chrome 77

**Uncaught TypeError: Cannot read property 'apply' of undefined**
**This error originated from your application code, not from Cypress.**
**When Cypress detects uncaught errors originating from your application it will automatically fail the current test.**
**This behavior is configurable, and you can choose to turn this off by listening to the 'uncaught:exception' event.**
**https://on.cypress.io/uncaught-exception-from-application**

The content of the file which creates an error in Cypress :

import { createStore, applyMiddleware, compose } from "redux";
import thunk from "redux-thunk";
import rootReducer from "./reducer";
const initialState = {};
const middleware = [thunk];
const store = createStore(
  rootReducer,
  initialState,
  compose(
    applyMiddleware(...middleware),
    window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
  )
);
export default store;
@jennifer-shehane
Copy link
Member

jennifer-shehane commented Oct 28, 2019

@Versifiction What happens when you turn off failing the test during uncaught exceptions? https://on.cypress.io/catalog-of-events#Uncaught-Exceptions

@Versifiction
Copy link
Author

Versifiction commented Oct 28, 2019

@Versifiction What happens when you turn off failing the test during uncaught exceptions? https://on.cypress.io/catalog-of-events#Uncaught-Exceptions

@jennifer-shehane I turned it off, but it's like it's still on..

Here's my cypress/support/index.js file :

Cypress.on("uncaught:exception", (err, runnable) => {
  // returning false here prevents Cypress from
  // failing the test
  return false;
});

Cypress.on("fail", (error, runnable) => {
  debugger;

  // we now have access to the err instance
  // and the mocha runnable this failed on

  throw error; // throw error to have test still fail
});

@jennifer-shehane
Copy link
Member

This is likely a duplicate of #987 with the uncaught exception being thrown from 3rd party code.

I will try to run the example against that PR to see if it is fixed. #5249

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Oct 29, 2019

@Versifiction I pulled down the repo provided and added the test below, with the uncaught exception handler. The test does indeed pass when given the uncaught:exception handler. Please use this as a workaround.

If this is not the error you were encountering, then provide the full set of tests please to reproduce.

support/index.js

Cypress.on("uncaught:exception", (err, runnable) => {
  // returning false here prevents Cypress from
  // failing the test
  return false;
});

spec.js

it('works', () => {
  cy.visit("http://localhost:3000")
})

Screen Shot 2019-10-29 at 11 33 09 AM

@cypress-io cypress-io locked and limited conversation to collaborators Jan 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants