jeudi 21 mai 2020

Check if element exist JEST tests

I'm trying to test if sgn.init() after call, generate and append element to DOM. However document.querySelector('.class') seems to always return null, even if I tried to add it manually in test function. Can You tell me what I'm doing wrong?

test('shoud be rendered', () => {
    sgn.init();
    const element = document.createElement('div');
    element.classList.add('.element');
    document.body.appendChild(element);
    console.log(document.querySelector('.element'))

});

Aucun commentaire:

Enregistrer un commentaire