dimanche 27 octobre 2019

Mocking with Jest

I am using Jest to test out my code.

jest
  .dontMock('fs')
  .dontMock('jquery');

var $ = require('jquery');
var html = require('fs').readFileSync('./index.html').toString();

describe("Test page index.html in main folder", () => {

  document.documentElement.innerHTML = html;

  it('changes text if click event is triggered', () => {
    $('button').click();
    expect($('button').text()).toEqual('text');    
  });

});

I am confused a bit as first I said don't use jquery ( .dontMock('jquery') ) but later on I used it. Am I thinking correctly?

Aucun commentaire:

Enregistrer un commentaire