Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [jest]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
0answers
25 views

Mocking CurrentPageReference wire in Jest unit tests - LWC

I have a LWC component which uses CurrentPageReference from lightning/navigation bundle in a @wire function. I am using lwc-jest to create unit tests for my components. Using the wire with ...
0
votes
0answers
43 views

Warning when dispatching ShowToastEvent

I'm trying to follow the pattern in https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.use_toast for displaying a toast message. However, whenever I do I get the following ...
2
votes
0answers
25 views

Warning when setting input value in test

I'm writing unit tests for LWC using lwc-jest but when I try to follow the pattern documented in the Basic Lightning Component section of this documentation https://developer.salesforce.com/docs/...
0
votes
0answers
63 views

Test cases for LWCs with conditional rendering

I have a LWC component which looks like below <template> <!-- modal start --> <template if:true={booleanField}> <lightning-record-edit-form object-api-name="...
0
votes
0answers
51 views

lightning-record-form onError jest test

I'm looking at writing a jest test for the lightning-record-form to test the error handling, The full function should be onError display a Toast event stating the error message to the user const ...
5
votes
0answers
113 views

My LWC test is not displaying code coverage

I have configured jest for Lightning web component test. My tests are running and passing but code coverage not displaying into output. Following is package.json file: - { "name": "my-...
4
votes
0answers
63 views

Jest Unit test an event that dispatches inside XMLHTTPRequest (XHR)

How do I test an event that does an XHR request and dispatches an event? I managed to install the dependencies to mock the xhr using https://github.com/jameslnewell/xhr-mock/tree/master/packages/xhr-...
1
vote
1answer
72 views

LWC Jest tests failing when adding variant to lightning-radio-group

This is similar to a previous question, however the context is different. We have developed a custom LWC that uses the lightning-radio-group component and sets the variant so we can hide the label (...
3
votes
1answer
53 views

Is Jest mandatory in LWC For appExchange app

As SF stated Jest is independent of Salesforce and doesn't run in web browser. Is it mandatory to write coverage/unit testing for Lightning Web Components and add in bundle while creating manage ...
2
votes
1answer
113 views

Run Single Test for Lightning Web Component

I feel like this is a stupid question, but I can't find the answer anywhere. Is there a way to run a single test file for a single Lightning Web Component. I essentially want to be able to pass ...
2
votes
1answer
284 views

How can I test the click of a button that calls an Apex method, and makes the component show a toast?

The component itself, when loaded, queries some data from the database. Then, depending on what it finds, loads the specific template. One of those has a button, which will call the server again, and ...
5
votes
1answer
270 views

How to mock navigator.geolocation in a LWC?

Having a component that uses the embedded geolocation feature to get coordinates, how can I mock the call in a Jest test? The component's code work in the org: ... get locationService () { ...
2
votes
1answer
628 views

How to test LWC onsuccess event handler in Jest

I'm looking for help writing jest test for my onsuccess event handler for my lightning-record-edit form. I'm new to jest so forgive me if this is covered somewhere else, I just haven't been able to ...
5
votes
1answer
114 views

How can I make sure, in an unit test, that I have the correct data in a lightning-map component?

If I have a property called markers in my component, which is exposed using the @api notation. How can I make sure that it contains the correct values after the component goes through the jest unit ...