Questions tagged [mock]
Mock classes are used in testing to simulate the responses of real code in a controlled, reproducible fashion. In particular, HTTPCalloutMock and WebServiceMock classes are used to supply response values to callouts made during a unit test.
9
questions
12
votes
3
answers
7k
views
LWC + Jest: Mocking imperative Apex and returning a value
I'm going to do a Q&A-style entry here, since I couldn't find anything on the web describing this use case. I have seen several threads here describing how to do an empty mock on an Apex call in ...
9
votes
2
answers
4k
views
Is there a way I can mock an AggregateResult?
I'm trying to write most of my tests without hitting salesforce database. For that I'm implementing some simple mock class where I just return some SOQL queries when needed. The problem I'm facing now ...
3
votes
2
answers
3k
views
Unit Testing External Object with Mocked Data
New to the SF dev world so I am struggling a bit with setting up some unit tests on external objects. I have found very little info on this, most dating back a few years.
I did find a post here on SO ...
3
votes
1
answer
3k
views
How do I mock a child LWC in a parent's Jest Unit Test?
I have two components that are in my app:
parentComponent
childComponent.
'parentComponent' includes 'childComponent' as a component.
E.g: parentComponent.html
<template>
<c-child-...
2
votes
1
answer
5k
views
How to mock custom LWC components in JEST
I am still new to JavaScript and especially Jest, so apologies in advance for the maybe stupid and uninformed question.
To isolate my tests, I want to mock one of my custom table components. In short,...
3
votes
0
answers
463
views
Mock a class that implements Schedulable using Stub API
I'm using Stub API (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_stub_api.htm) to mock a class that implements Schedulable and because of this I'm getting an ...
1
vote
1
answer
2k
views
how to mock Object list in a test class?
This is a method in my apex controller class:
@AuraEnabled
public static void sendMail(List<Object> selectedRows) {
if (selectedRows.size() > 0) {
for (Object obj : ...
1
vote
1
answer
212
views
Problems with callouts Mock and tests
We have a problem in our organization and I was hoping for some advice from you on how to best tackle this.
We have a handler class that makes a callout to a Master Data Management system for account ...
0
votes
1
answer
1k
views
Testing/Mocking design pattern to test Messaging.SendEmailResult
I have some code in an After Insert trigger that does some conditional DML updates to the records being inserted if a mail is successfully sent out. I'm looking for a solid, modular way to test this, ...