I create LWC component that contains wire service with importing getRelatedListRecords function. and its work normal. but the problem is when I create the test using jest-test I don't know why I always getting this following error I already follow the documentation but always still got those module not found error. and here my lwc-test:
import { createElement } from 'lwc';
import RelatedRecordDetailList from 'c/relatedRecordDetailList';
import { getRelatedListRecords } from 'test/jest-mocks/lightning/uiRelatedListApi';
const mockGetRecord = require("./data/getRelatedListRecords.json");
describe('c-related-record-detail-list', () => {
afterEach(() => {
// The jsdom instance is shared across test cases in a single file so reset the DOM
while (document.body.firstChild) {
document.body.removeChild(document.body.firstChild);
}
});
test('display_realted_list_record', () => {
// Arrange
const element = createElement('c-related-record-detail-list', {
is: RelatedRecordDetailList
});
// Act
document.body.appendChild(element);
getRelatedListRecords.emit(mockGetRecord);
// Assert
// const div = element.shadowRoot.querySelector('div');
return Promise.resolve().then(() => {
const content = element.shadowRoot.querySelector(".slds-box");
expect(content.length).toBe(3);
});
});
});
Anyone facing something like that? can you help me guys, please?
Thanks in advance