sfdx-lwc-jest
sfdx-lwc-jest copied to clipboard
Add Flowsupport stub into lightning stubs
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
- @salesforce/sfdx-lwc-jest: 1.0.1
- Node: 14.17.5
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
}
});
}
}
@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
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.
with the release of the lightning/flow module it would be great if that could be supported as well.
Is this ever intended to be doable, and if not what alternative for testing is officially recommended?