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

cy.task() fails when spec file name contains "em dash" #31034

Open
maximilianschmid opened this issue Feb 6, 2025 · 0 comments · May be fixed by #31037
Open

cy.task() fails when spec file name contains "em dash" #31034

maximilianschmid opened this issue Feb 6, 2025 · 0 comments · May be fixed by #31037
Assignees
Labels
stage: investigating Someone from Cypress is looking into this type: bug

Comments

@maximilianschmid
Copy link

maximilianschmid commented Feb 6, 2025

Current behavior

When running this test code in a .spec file called task.spec.js the test works.

If it is run in a spec file with a em dash in it, eg. ta—sk.spec.js the test fails.

Image

Desired behavior

Test should also work in a spec file which contains a em dash (—) in the file name.

Test code to reproduce

// add testTask in cypress/plugins/index.js

// module.exports = (on, config) => {
//   on('testTask', {
//     test: () => Promise.resolve(true),
//   })
//
//   return config
// }

describe('test', () => {
  it('test', () => {
    cy.task('testTask')
  })
})

Cypress Version

14.0.2

Node version

v20.18.1

Operating System

Mac OS 15.3

Debug Logs

CypressError
cy.task() must only be invoked from the spec file or support file.
cypress/e2e/APP/download/ta—sk.spec.js:13:8

  11 | describe('test', () => {
  12 |   it('test', () => {
> 13 |     cy.task('testTask')
     |        ^
  14 |   })
  15 | })
  16 |

Other

No response

@maximilianschmid maximilianschmid changed the title cy.task check if run in spec file fails if spec file name contains "em dash" - or long dash cy.task() check fails if spec file name contains "em dash" Feb 6, 2025
@maximilianschmid maximilianschmid changed the title cy.task() check fails if spec file name contains "em dash" cy.task() fail if spec file name contains "em dash" Feb 6, 2025
@maximilianschmid maximilianschmid changed the title cy.task() fail if spec file name contains "em dash" cy.task() fails when spec file name contains "em dash" Feb 6, 2025
@AtofStryker AtofStryker self-assigned this Feb 6, 2025
@jennifer-shehane jennifer-shehane added the stage: investigating Someone from Cypress is looking into this label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: investigating Someone from Cypress is looking into this type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants