SFDC Interview Questiosn Part 5
SFDC Interview Questiosn Part 5
Pu
blic
3
4export default class Component1 extends LightningElement {
5 // Component 1 logic
6}
javascript
Pu
blic
8 document.body.appendChild(element);
9
10 expect(element.shadowRoot.textContent).toBe('Hello, LWC!');
11 });
12});
Explanation: In the example code above, we have an LWC
component 'MyComponent' and a Jest unit test that verifies the correct rendering
of the component. By creating an instance of the component and asserting the
expected output, you can ensure its functionality.
1<template>
2 <lightning-record-edit-form object-api-name="Account">
3 <lightning-messages></lightning-messages>
4 <lightning-input-field field-name="Name"></lightning-input-field>
5 <lightning-input-field field-name="Phone"></lightning-input-field>
6 <lightning-input-field field-name="Website"></lightning-input-field>
7 <lightning-button type="submit" label="Save"></lightning-button>
8 </lightning-record-edit-form>
9</template>
Explanation: In the example code above, we have a form that utilizes the Lightning
Data Service to create or update Account records. The 'lightning-record-edit-
form' component handles the data operations, allowing users to input and save
record details.
Pu
blic
queries, display a subset of records, and provide navigation controls to switch
between pages.
1<template>
2 <lightning-datatable data="{visibleData}" columns="{columns}" key-field="Id" hide-checkb
3 <lightning-button-group>
4 <lightning-button label="Previous" onclick="{handlePrevious}"></lightning-button>
5 <lightning-button label="Next" onclick="{handleNext}"></lightning-button>
6 </lightning-button-group>
7</template
avascript
Pu
blic