mercredi 3 juin 2020

Testing private method using spyOn and Jest

My functions in Calculator class is private and I can't test in this way,

describe('calculate', function() {
  it('add', function() {
    let result = Calculator.Sum(5, 2);
    expect(result).toBe(7);   
  });

  it('substract', function() {
    let result = Calculator.Difference(5, 2);
    expect(result).toBe(3);
  });
});

how can I modify this test with using spyOn on private methods?

thanks for any help

Aucun commentaire:

Enregistrer un commentaire