sampleDemo.html
<template>
<p>Brahmanaidu</p>
<h1>Mandalapu</h1>
<b>Welcome to sfdcscenarios</b>
</template>
sampleDemo.test.js
import {createElement} from 'lwc';
import SampleDemo from 'c/sampleDemo';
describe('c-sample-demo',()=>{
beforeEach(()=>{
const element=createElement('c-sample-demo',{
is:SampleDemo
});
document.body.appendChild(element)
})
test('testing paragraph',()=>{
const element=document.querySelector('c-sample-demo');
const pTxt=element.shadowRoot.querySelector('p');
expect(pTxt.textContent).toBe('Brahmanaidu');
})
test('testing header tag',()=>{
const element=document.querySelector('c-sample-demo');
const hTxt=element.shadowRoot.querySelector('h1');
expect(hTxt.textContent).toBe('Mandalapu');
})
test('testing bold tag',()=>{
const element=document.querySelector('c-sample-demo');
const hTxt=element.shadowRoot.querySelector('b');
expect(hTxt.textContent).toBe('Welcome to sfdcscenarios');
})
})
Comments
Post a Comment