1

I get this error:

Cannot find module 'lightning/quickActionPanel'

when running this Jest test:

import { createElement } from 'lwc';
import DuplicateScreenAction from 'c/duplicateScreenAction';

let componentElement = null;

describe('DuplicateScreenAction', () => {
    beforeEach(() => {
        componentElement = createElement('c-duplicateScreenAction', {
            is: DuplicateScreenAction
        });
    });

    afterEach(() => {
        while (document.body.firstChild) {
            document.body.removeChild(document.body.firstChild);
        }
    });

    it('component created', () => {
        document.body.appendChild(componentElement);
        expect(componentElement).not.toBe(null);
    });
});

where the duplicateScreenAction custom LWC HTML includes lightning-quick-action-panel which is documented as beta. The component works fine in the product desktop. Other Jest tests work fine.

Am I missing something here e.g. are beta components excluded from LWC Jest?

I have run sfdx update and npm update.

PS

I get a similar error for this:

import { CloseActionScreenEvent } from 'lightning/actions';

Background info here Create Screen Quick Actions.

1 Answer 1

1

Even though you ran npm update, your sfdx-lwc-jest node dependency must point to an older version. Your package.json will show this within devDependencies (I ran into a similar issue).

If you update your version to the most recent listed here within your package.json

"devDependencies": {
    ...
    "@salesforce/sfdx-lwc-jest": "^1.0.0",
    ...
}

and then run npm install, that should solve your issue as it'll get you the latest jest version.

For background, LWC quick action panel is GA in Summer '21 and, if you take a peek at the jest repo, you can see they added the stubs for lightning-quick-action-panel within this PR.

There's even example jest tests for LWC quick actions in the lwc-recipes and one utilizing CloseActionScreenEvent as well.

5
  • Yep mine was set to 0.10.4. Thanks for the very clear and helpful answer!
    – Keith C
    Jul 21, 2021 at 6:44
  • After the version change, I've run into "TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined" which is an undefined options value being passed through to a crypto reference. Presume you didn't hit that?
    – Keith C
    Jul 21, 2021 at 7:43
  • 1
    I didn't, but that error seems to be referenced in this issue. There's a PR referenced to fix it, but hasn't been merged yet. Jul 21, 2021 at 12:29
  • Thanks again Kris; I'll watch out for a new version.
    – Keith C
    Jul 21, 2021 at 12:40
  • 1
    @KeithC, looks like the PR closed (version 1.0.1) and that should fix that error you saw. Jul 22, 2021 at 17:45

You must log in to answer this question.

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