salesforce / sfdx-lwc-jest

Run Jest against LWC components in SFDX workspace environment
MIT License
164 stars 81 forks source link

Add Flowsupport stub into lightning stubs #244

Open jefersonchaves opened 3 years ago

jefersonchaves commented 3 years ago

Description

Steps to Reproduce

// simplified test case
it('navigates to next event ...', () => {
    ...
});
// JS for component under test
import { LightningElement } from 'lwc';
import { FlowNavigationNextEvent } from "lightning/flowSupport";

export default class Foo extends LightningElement {
    goToNextStep() {
        this.dispatchEvent(new FlowNavigationNextEvent());
    }
}

Expected Results

Being able to test components that use lightning/flowSupport and potentially validate that event was dispatched.

Actual Results

Cannot find module 'lightning/flowSupport' from 'force-app'

Version

Possible Solution

I currently added the following stub but is incomplete and requires duplication for the projects - I can happily submit a pull request for review (this was my starting point):

export const FlowAttributeChangeEventName = 'lightning__flowattributechange';

export class FlowAttributeChangeEvent extends CustomEvent {
 constructor(attributeName, attributeValue) {
    super(FlowAttributeChangeEventName, {
        composed: true,
        cancelable: true,
        bubbles: true,
        detail: {
            attributeName,
            attributeValue
        }
    });
  }
}

export const FlowNavigationNextEventName = 'lightning__flownextevent';

export class FlowNavigationNextEvent extends CustomEvent {
 constructor(attributeName, attributeValue) {
    super(FlowNavigationNextEventName, {
        composed: true,
        cancelable: true,
        bubbles: true,
        detail: {
            attributeName,
            attributeValue
        }
    });
  }
}
djsing commented 2 years ago

@jefersonchaves Would you mind sharing your completed stub? I assume you completed your stub since then, but I can't seem to find your PR. It would really help me :) thanks. If you can't, the above is still a good starting point.

PS. its kind of crazy that no one has responded to such a needed issue

jefersonchaves commented 2 years ago

Hello @djsing - To be honest I got involved into other projects and I feel I have never submitted a PR. The starting point still what I described here. I hope it helps you.

rgoodman22 commented 1 year ago

with the release of the lightning/flow module it would be great if that could be supported as well.

jonnypetraglia commented 9 months ago

Is this ever intended to be doable, and if not what alternative for testing is officially recommended?