2

need one help from the community below is my code for the JEST testing for one of my component.

import { createElement } from 'c/meetingRooms';
import MeetingRooms from 'c/meetingRooms';

describe('c-meetingRooms', () => {
    afterEach( () => {
        while (document.body.firstChild) {
            document.body.removeChild(document.body.firstChild);
        }
    })

    it('count number of meeting rooms component', () => {

        const meetingRooms = createElement('c-meetingRooms', { is: MeetingRooms });
        document.body.appendChild(meetingRooms);

        const allMeetingRoomsComponent = meetingRooms.shadowRoot.querySelectorAll('c-meeting-room');
        expect(allMeetingRoomsComponent.length).toBe(7);

    });

});

Error i am getting as below:

-meetingRooms
    × count number of meeting rooms component (2ms)

  ● c-meetingRooms › count number of meeting rooms component

    TypeError: (0 , _meetingRooms.createElement) is not a function

it will be great if anyone can help me out. Thanks

1 Answer 1

4

Never mind i got it working as "import { createElement } from 'c/meetingRooms';" it should be "import { createElement } from 'lwc';"

1
  • Feel free to mark this answer as the accepted answer so it doesn't show up in the "unanswered" list :) Commented Jun 22, 2020 at 21:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .