filiphric / cypress-plugin-api

Cypress plugin to show your API information in the Cypress UI runner
ISC License
264 stars 35 forks source link

Plugin fails with "a.replace is not a function" #109

Closed juan-belmonte closed 1 year ago

juan-belmonte commented 1 year ago

Environment

Cypress package version: 12.4.0 Cypress binary version: 12.4.0 Electron version: 21.0.0 Bundled Node version: 16.16.0 cypress-plugin-api: 2.10.0

Issue description

I'm running a set of API tests against different environments:

When I run Cypress against the local environment, everything works as expected. But when running against the dev environment, the plugin crashes:

react_devtools_backend.js:4012 

       TypeError: a.replace is not a function
    at o (webpack:///./node_modules/cypress-plugin-api/dist/support.js:9:212)
    at Array.map (<anonymous>)
    at Object.o [as encode] (webpack:///./node_modules/cypress-plugin-api/dist/support.js:9:212)
    at Object.highlight (webpack:///./node_modules/cypress-plugin-api/dist/support.js:9:3805)
    at P (webpack:///./node_modules/cypress-plugin-api/dist/support.js:10:1036)
    at Fe (webpack:///./node_modules/cypress-plugin-api/dist/support.js:12:1510)
    at Context.eval (webpack:///./node_modules/cypress-plugin-api/dist/support.js:14:2091)
From previous event:
    at Context.thenFn (https://dev.company.com/__cypress/runner/cypress_runner.js:135668:63)
    at Context.then (https://dev.company.com/__cypress/runner/cypress_runner.js:135917:21)
    at wrapped (https://dev.company.com/__cypress/runner/cypress_runner.js:151098:19)
    at <unknown> (https://dev.company.com/__cypress/runner/cypress_runner.js:149957:15)
From previous event:
    at CommandQueue.runCommand (https://dev.company.com/__cypress/runner/cypress_runner.js:149923:8)
    at next (https://dev.company.com/__cypress/runner/cypress_runner.js:150123:19)
    at <unknown> (https://dev.company.com/__cypress/runner/cypress_runner.js:150144:16)
From previous event:
    at next (https://dev.company.com/__cypress/runner/cypress_runner.js:150123:39)
From previous event:
    at <unknown> (https://dev.company.com/__cypress/runner/cypress_runner.js:163626:77)
From previous event:
    at CommandQueue.run (https://dev.company.com/__cypress/runner/cypress_runner.js:163621:21)
    at CommandQueue.run (https://dev.company.com/__cypress/runner/cypress_runner.js:150187:15)
    at $Cy.runQueue (https://dev.company.com/__cypress/runner/cypress_runner.js:151078:14)
    at cy.<computed> [as runExample] (https://dev.company.com/__cypress/runner/cypress_runner.js:151160:12)
    at runnable.fn (https://dev.company.com/__cypress/runner/cypress_runner.js:151339:19)
    at callFn (https://dev.company.com/__cypress/runner/cypress_runner.js:104935:21)
    at ../driver/node_modules/mocha/lib/runnable.js.Runnable.run (https://dev.company.com/__cypress/runner/cypress_runner.js:104922:7)
    at <unknown> (https://dev.company.com/__cypress/runner/cypress_runner.js:158288:30)
From previous event:
    at Object.onRunnableRun (https://dev.company.com/__cypress/runner/cypress_runner.js:158271:53)
    at $Cypress.action (https://dev.company.com/__cypress/runner/cypress_runner.js:147586:28)
    at Runnable.run (https://dev.company.com/__cypress/runner/cypress_runner.js:156289:13)
    at ../driver/node_modules/mocha/lib/runner.js.Runner.runTest (https://dev.company.com/__cypress/runner/cypress_runner.js:105594:10)
    at <unknown> (https://dev.company.com/__cypress/runner/cypress_runner.js:105720:12)
    at next (https://dev.company.com/__cypress/runner/cypress_runner.js:105503:14)
    at <unknown> (https://dev.company.com/__cypress/runner/cypress_runner.js:105513:7)
    at next (https://dev.company.com/__cypress/runner/cypress_runner.js:105415:14)
    at <unknown> (https://dev.company.com/__cypress/runner/cypress_runner.js:105481:5)
    at timeslice (https://dev.company.com/__cypress/runner/cypress_runner.js:99407:27)
overrideMethod @ react_devtools_backend.js:4012
logError @ index-5879cbca.js:101743
(anonymous) @ index-5879cbca.js:107810
emit @ index-5879cbca.js:107396
(anonymous) @ cypress_runner.js:177918
emit @ cypress_runner.js:18373
emit @ cypress_runner.js:177980
onPrint @ cypress_runner.js:176860
_onPrintClick @ cypress_runner.js:176864
(anonymous) @ cypress_runner.js:178101
executeAction @ cypress_runner.js:45275
n @ cypress_runner.js:45275
ca @ cypress_runner.js:55921
ja @ cypress_runner.js:55922
ka @ cypress_runner.js:55922
wa @ cypress_runner.js:55924
Aa @ cypress_runner.js:55925
ya @ cypress_runner.js:55925
Da @ cypress_runner.js:55928
Ad @ cypress_runner.js:55991
Gi @ cypress_runner.js:56157
Kb @ cypress_runner.js:55946
Dd @ cypress_runner.js:55993
(anonymous) @ cypress_runner.js:56158
../../node_modules/scheduler/cjs/scheduler.production.min.js.exports.unstable_runWithPriority @ cypress_runner.js:59656
Ii @ cypress_runner.js:56158
Cd @ cypress_runner.js:55992

The plugin fails and Cypress is showing that failure instead of the assertion error (status code mismatch).

martin131 commented 1 year ago

Same problem on my tests. Moved back to cy.request

filiphric commented 1 year ago

Hey there! Thanks for the report! I will do my best to take a look into this issue this week. If there's a way for you to provide information about the request and response body, it would be very helpful. Apparentl, the plugin is trying to parse something, but throws an error instead. I need to be able to narrow down what exactly is throwing this error and fix it. Thanks in advance!

denisconekta commented 1 year ago

same problem; weird thing is that other colleagues working on same tests don't have the issue.

filiphric commented 1 year ago

I tried fixing the issue but since I had not reproduction, my fix is only a guess on might have caused the issue. Please update to v 2.10.1 and if the issue persists, feel free to reopen the issue and kindly provide me with a reproduction repository or at least an example of response, including response headers that cause this issue.

filiphric commented 1 year ago

Alirght I haven’t fixed it, thank you @martin131 for helping me debug this. it seems that there’s an error in how different formats are resolved.

martin131 commented 1 year ago

Works for me in the latest version 2.10.3. Thank you!

denisconekta commented 1 year ago

Whit the new version of the plugin works perfect. Thanks @filiphric !

juan-belmonte commented 1 year ago

I confirm that version 2.10.3 also solves the issue for me. Thank you very much, @filiphric. Please excuse I didn't provide any further information before you solved it.

ncrco commented 6 months ago

Hello, I have the same error, but I don't know how to solve it, regardless of the version the error continues. @filiphric

ncrco commented 6 months ago

From yesterday to today I was racking my brains trying to fix a bug that exists within the node modules of the Cypress plugin and, like, a horrible error that keeps returning a false negative, informing that R is not a function. If this happens to you, there is a very simple way to fix it, Cypress will identify the file that has the bug and you will need to enter the file and modify it by transforming that R into a string. It was the only way I found to handle it, with a lot of help from the university students, in the end the test passed. @filiphric

error: Imagem do WhatsApp de 2024-04-30 à(s) 10 17 26_74fa2a8a

solution:

image