Questions tagged [jest]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
20 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
37 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
38 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
38 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
40 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
70 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
139 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
204 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
408 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
76 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 ...