How to spy on an imported function with Cypress in typescript

Viewed 688

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');
  })
}) 
0 Answers
Related