NeuraLegion / cypress-har-generator

Cypress plugin for generating HTTP Archive (HAR) files captures network requests during Cypress tests.
https://www.npmjs.com/package/@neuralegion/cypress-har-generator
MIT License
80 stars 18 forks source link

cy.saveHar is not a function #396

Open zubairPlanera opened 8 months ago

zubairPlanera commented 8 months ago

Current behavior Description: Encountering an issue where the cy.saveHar function is not recognized in my Cypress setup, despite following the correct implementation steps.

Environment:

Node.js version: v18.4.0 Cypress version: 13.5.1 Operating System: macOs Monterey Error Message: Cypress throws an error, stating that cy.saveHar is not a function when attempting to utilize it in the test file. Steps Taken:

Installed @neuralegion/cypress-har-generator as a development dependency. Updated cypress/plugins/index.js and cypress.config.js as per the plugin documentation. Registered commands in cypress/support/index.js. Implemented code in the test file to generate and save a HAR file. Additional Information:

Confirmed correct plugin installation. Cypress plugin setup appears to be correctly configured. cypress/support/index.js is properly set up. Other plugin functions (e.g., cy.recordHar()) are working as expected. Desired behavior Expect cy.saveHar to be recognized as a valid Cypress command and save the generated HAR file.

Test code to reproduce describe.only('Project Creation', () => {

let projectName

before(() => { cy.viewport(viewportsize) cy.recordHar(); cy.loginDevPlanera() projectName = createProjectPageConstant.generateProjectName() })

after(() => { cy.logout(); cy.saveHar(); })

it('TC1| Create Project, [Smoke-Test]', { tags: ['Smoke'] }, () => { cy.log('Project Creation Initiated') createCanvasObject.createProject(projectName) cy.log('Project Creation completed')

})

})

Cypress Version 13.5.1

Node version 18.4.0

Operating System macOS 12.0

Debug Logs No response

Other Possible Solutions Attempted:

Restarted Cypress. Verified Cypress version compatibility. Checked and ensured correct plugin implementation based on documentation.

sadhishsk commented 7 months ago

@derevnjuk Even I face the same issue in my current setup. Cypress-har-generator is not compatible with Cypress 13.6.4. In my case, its showing cy.task('recordHar')failed with the following error: > Failed to connect to Chrome Debugging Protocol Possible reasons for failure: - Chrome not running in headless mode - Using Chrome version 58 or earlier - Inconsistent RDP configuration settings. The stack trace for this error is: https://on.cypress.io/api/task Because this error occurred during abefore each` hook we are skipping all of the remaining tests.

bartonhammond commented 6 months ago

Any update?