Skip to content

Cypress 15 node crypto #32305

@prescottprue

Description

@prescottprue

Current behavior

When updating to Cypress 15 we see an issue using Node's crypto and a custom command (which was not an issue in Cypress 14 and earlier):

crypto__WEBPACK_IMPORTED_MODULE_0___default(...).createHmac is not a function

The code which triggers this error is within support/commands.ts:

import crypto from 'crypto'

// then later
const hash = crypto.createHmac('sha256', secret)
               .update('I love cupcakes')
               .digest('hex');

When running the repro with a fork of cypress-test-tiny I see the same thing

Desired behavior

Usage of node packages such as Crypto should still work as expected. If we have to do something like putting this login in cypress task called by a command, a named import instead of default import (import { createHmac } from 'crypto') or node prefix in import (import crypto from 'node:crypto') I would expect that to be called out in the docs and/or in the version changelog (though neither of the import changes worked)

Test code to reproduce

prescottprue/cypress-test-tiny#1

Cypress Version

15.0.0

Node version

v22.14.0

Operating System

macOS 15.6

Debug Logs

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions