import { createElement } from 'lwc';
import testComponent from 'c/...';
import LightningConfirm from 'lightning/confirm';
describe('testComponent', () => {
jest.mock('lightning/confirm');
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);
}
});
it('TODO: test case generated by CLI command, please fill in test logic', () => {
LightningConfirm.open = jest.fn().mockResolvedValue(true);
// Arrange
const element = createElement('testComponent', {
is: testComponent
});
// Act
document.body.appendChild(element);
// Assert
// const div = element.shadowRoot.querySelector('div');
expect(1).toBe(1);
});
});
Error in test:
Cannot find module 'lightning/confirm' from 'src/lwc/testComponent/testComponent.js'
Description
I have a component where connected lightning confirm component(https://developer.salesforce.com/docs/component-library/bundle/lightning-confirm/documentation). When I run a test for my component, I am getting error that Cannot find module 'lightning/confirm'. But it is feature is part of salesforce library and there should not be any problem with it.
Steps to Reproduce
My component:
Test as generated by default
Error in test: Cannot find module 'lightning/confirm' from 'src/lwc/testComponent/testComponent.js'
Version