NeuraLegion/cypress-har-generator

cy.saveHar is not a function

zubairPlanera opened this issue · 2 comments

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.

@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.

Any update?