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: path must be a string to res.sendFile #26059

Closed
Xhuljano-Racaku opened this issue Mar 8, 2023 · 6 comments
Closed

TypeError: path must be a string to res.sendFile #26059

Xhuljano-Racaku opened this issue Mar 8, 2023 · 6 comments
Assignees
Labels
topic: installation Issue during installation or downloading Cypress

Comments

@Xhuljano-Racaku
Copy link

Xhuljano-Racaku commented Mar 8, 2023

Current behavior

I am trying to write my first e2e test in angular but I am getting this error TypeError: path must be a string to res.sendFile, so I am not able to run the test. How can I solve this issue?
My cypress.json looks like this

 "**fileServerFolder**": "e2e/tsconfig",
  "**fixturesFolder**": "e2e/src/fixtures",
  "**integrationFolder**": "e2e/src/integration",
  "**pluginsFile**": "e2e/src/plugins/index",
  "**supportFile**": false,
  "**video**": true,
  "**videosFolder**": "reports/tests/cypress/videos",
  "**screenshotsFolder**": "reports/tests/cypress/screenshots",
  "**chromeWebSecurity**": false,
  "**modifyObstructiveCode**": false,
  "**env**": {
    "**tsConfig**": "tsconfig.json"
  }
}

My **tsconfig.json** looks:
{
  "**extends**": "../tsconfig.json",
  "**compilerOptions**": {
    "types": [
      "cypress",
      "node"
    ],
    "**declaration**": false,
    "**sourceMap**": false,
    "**outDir**": "../dist/out-tsc/e2e"
  },
  "**include**": [
    "**/*.ts",
    "*.js"
  ]
}

The structure of the folders is | e2e > tsconfig.json |cypress.json
Please any help would be appreciated

Debug logs

No response

Cypress Version

9.1.0

Node version

14.18.16

Package Manager

npm

Package Manager Version

1.3.2691

Operating system

Windows

Operating System Version

21H2

Other

No response

@Xhuljano-Racaku Xhuljano-Racaku added the topic: installation Issue during installation or downloading Cypress label Mar 8, 2023
@mike-plummer
Copy link
Contributor

@Xhuljano-Racaku Sorry to hear you're having issues, but we will need a bit more info in order to help diagnose your issue. Could you explain where you're encountering that error and attach the logging output of your failing test? Is it possible to share a reproduction of the error? It's much more likely we can identify and assist with your issue if a reproduction case is supplied.

@Xhuljano-Racaku
Copy link
Author

I am not able to attach a screenshot, but I will copy and paste everything in here.. This error occur when I run e2e testing. Once I type that command thats what happens

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 9.1.0 │
│ Browser: Electron 94 (headless) │
│ Node Version: v14.20.0 (C:\Program Files\nodejs\node.exe) │
│ Specs: 1 found (app.spec.js) │
│ Searched: e2e\src\integration*** │
└────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────

Running: app.spec.js

Oops...we found an error preparing this test file:

e2e\src\integration\app.spec.js

The error was:

TypeError: path must be a string to res.sendFile
at ServerResponse.sendFile (C:\Users\uwry\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\node_modules\express\lib\response.js:415:11)
at tryCatcher (C:\Users\uwry\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\util.js:16:23)
at ret (:14:23)
at C:\Users\uwry\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\lib\controllers\spec.js:44:14
at tryCatcher (C:\Users\uwry\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (C:\Users\uwry\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:547:31)
at Promise._settlePromise (C:\Users\uwry\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromiseCtx (C:\Users\uwry\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:641:10)
at _drainQueueStep (C:\Users\uwry\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:97:12)
at _drainQueue (C:\Users\uwry\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:86:9)
at Async._drainQueues (C:\Users\uwry\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\uwry\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:15:14)
at processImmediate (node:internal/timers:464:21)

This occurred while Cypress was compiling and bundling your test code. This is usually caused by:

  • A missing file or dependency
  • A syntax error in the file or one of its dependencies

Fix the error in your code and re-run your tests.
(Results)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 0 │
│ Passing: 0 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 0 seconds │
│ Spec Ran: app.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘

(Video)

  • Started processing: Compressing to 32 CRF
  • Finished processing: C:\Users\uwry\Desktop\cash-transfer.webapp\reports\tests\cy (0 seconds)
    press\videos\app.spec.js.mp4

====================================================================================================

(Run Finished)

   Spec                                              Tests  Passing  Failing  Pending  Skipped

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ app.spec.js 0ms - - 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✖ 1 of 1 failed (100%) 0ms - - 1 - -

@mike-plummer
Copy link
Contributor

@Xhuljano-Racaku It appears you have an issue with the preprocessor stage - are you using a preprocessor or other plugins? If you temporarily remove them does the problem go away? If so you should verify you have them correctly configured - there are older issues in the repo that suggest potential fixes

@Xhuljano-Racaku
Copy link
Author

Xhuljano-Racaku commented Mar 9, 2023

Yes, you are right. When I removed the pluginsFile from cypress.json it works. I have tried so many things but it looks I can't figure it out. I already checked potentail fixes and still can't get it work. This is how my index.js looks:

const registerTasks = require('../plugins');
module.exports = (on, config) => {
  on('file:preprocessor', () => {
    registerTasks(on, config);
    return config;
  });
};

@Xhuljano-Racaku
Copy link
Author

I was able to figure it out. Thanks for your help. You can close this issue

@mike-plummer
Copy link
Contributor

@Xhuljano-Racaku I assume the file you embedded above is your /cypress/plugins/index.js file. If that's the case you might want to validate the path you're attempting to require - should it be ./plugins instead of ../plugins?

@mike-plummer mike-plummer closed this as not planned Won't fix, can't repro, duplicate, stale Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: installation Issue during installation or downloading Cypress
Projects
None yet
Development

No branches or pull requests

2 participants