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

TypeError: Cannot read properties of undefined (reading 'split') #18557

Closed
alycda opened this issue Oct 20, 2021 · 2 comments
Closed

TypeError: Cannot read properties of undefined (reading 'split') #18557

alycda opened this issue Oct 20, 2021 · 2 comments
Labels
pkg/server This is due to an issue in the packages/server directory stale no activity on this issue for a long period type: bug

Comments

@alycda
Copy link

alycda commented Oct 20, 2021

Current behavior

when utilizing cypress-wait-until and returning false via Promise rejection, the error message is not displayed as expected:

Screen Shot 2021-10-19 at 9 47 11 PM

see https://github.com/NoriSte/cypress-wait-until/blob/master/src/index.js#L62
and https://github.com/cypress-io/cypress/search?q=splitStack (specifically

const lines = stack.split('\n')
)

Desired behavior

Cypress should display the error message regardless of whether a stack trace is available

Test code to reproduce

cypress/support/commands/ts

import 'cypress-wait-until';

...

Cypress.Commands.add('waitForReduxAction', (type: string, payload?: any) => {
  cy.wrap(type, { log: false }).waitUntil(
    (actionType) =>
      cy.window().then(
        (win) =>
          new Cypress.Promise((resolve, reject) => {
            // win.db is instance of IndexedDB
            const actionObjectStore = win.db.transaction('actions').objectStore('actions');

            const index = actionObjectStore.index('type'); // TODO: filter by payload
            index.get(actionType).onsuccess = function (event) {
              // console.warn(event.target.result); debugger;

              if (event.target.result) {
                resolve(true);
              } else {
                reject(false); // this reject triggers the TypeError
              }
            };
          }),
      ),
    {
      customMessage: type,
      // verbose: true,
      errorMsg: `action "${type}" never fired`, // TypeError: Cannot read properties of undefined (reading 'split')     at splitStack
    },
  );
});

cypress/integration/my.spec.ts

...
cy.waitUntil(() => false); // throws error as expected
cy.waitForReduxAction('@@channel/SIGNAL/openChannels'); // if promise rejects, triggers the Type Error
...

Cypress Version

7.6.0

Other

seems to be an issue with promises, as cy.waitUntil(() => false); returns a usable Error Message:

Screen Shot 2021-10-19 at 9 53 17 PM

@emilyrohrbough emilyrohrbough added type: bug pkg/server This is due to an issue in the packages/server directory labels Nov 17, 2022
@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 17, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/server This is due to an issue in the packages/server directory stale no activity on this issue for a long period type: bug
Projects
None yet
Development

No branches or pull requests

3 participants