mardi 23 mars 2021

How to spy on an imported function with Cypress in typescript

In Cypress when spying on a function, the syntax is cy.spy(object, method), but I would like to spy on a function imported from another file that isn't in an object. Is this possible?

Note: I've tried the following way as well, which doesn't seem to work.

//import { func } from 'src/file';
import * as funcObj from 'src/file';

describe('test', () => {
  it('test', () => {
    cy.spy(funcObj, 'func');
  })
}) 

Aucun commentaire:

Enregistrer un commentaire