Category "mocking"

Fake client behaviour when mocking k8s for testing

I am using the fake clientset to perform some mocking in a k8s cli tool I am creating. Therefore I am creating a Job resource jobs := clientset.BatchV1().Jobs(m

Mocking Bull queues in NestJS

I am trying to test that after sending a request to one of my controllers, the queue pushes a job. Implementation itself works as expected. This is my app.modul

Mock grpc service in unit testing nestjs

I want write an unit test for my getAllGroups() method in mail.service.ts: public async getAllGroup(): Promise<{ id: number, name: string }[]> { try {

Problem with exception handling using Python requests module

The following part of my code is supposed to do exception handling during HTTP requests. app.py class Get: def __init__(self, url): self.url = url

How to mock a constructor which is throwing a IOException with mockito-inline?

How can i mock the next lines: Workbook templateWorkBook = null; try { templateWorkBook = new XSSFWorkbook(templateWithoutEvents); } catch (IOException ex){

CRA - window object is undefined - jest/react

I have an issue in my tests that flag up a window variable as undefined. But I don't know where in the setupTests.tsx, I would need to define it. So far the var

NestJS Testing ConfigService works

I am writing an application to handle requests and return predefined responses to allow testing of external REST endpoints by software that cannot have internal

Simplifying AWS SDK GO v2 testing/mocking

Amazon has a super useful article describing how to unit test AWS SDK Go v2. I understand their motivation to depart from the "old" way of unit testing the v1

In Jest, how do I mock a Promise of void?

I'm using Jest and Typescript. I have a async function that returns nothing (void). How do I mock returning void? I tried the below const myMockFn = jest.fn(

Angular Test: Mocking Viewchild projected component and observable property

I have the following code that I can't mock in my unit tests: @ContentChild(CarouselInfoComponent) carouselInfo: CarouselInfoComponent; @ContentChild(Carous

How to mock only one typescript class from a module, but leave other classes/functions as is, using the jest framework

I have a typescript module with a function that I'm trying to test with jest. The function I'm trying to test uses a typescript class that's defined in the same

How to mock a 'request' node module for testing in jest

I am new to writing test cases in jest and i wanted to test 'mark' function and want to mock 'request' node module. let's say this file's name is app.js and tes

Im not able to mock ServiceBusReceivedMessage and ServiceBusMessageActions

we want to write unit-test for servicebus message trigger. we are using Azure.Messaging.ServiceBus nuget package [FunctionName("serviebustrigger")] publi

how to mock slack web api for jest

i have an app that's using the @slack/web-api package through the named import WebClient. i want to test one of the controllers that uses a model that in turns

How to mock method of a mocked class

Changed the titel to a more common one. I guess the problem is not that class specific. I want to mock google.cloud.pubsub_v1.SubscriberClient I want to set a f

Is there a way to mock Random.Next regardless of what gets passed to it and where it gets called?

I have the following method I wish to unit test: public class Board { public static BoardElement RandomElement(List<BoardElement> elements) {

Mocking federated modules in host application for jest

Question is exactly same here in fact but has different context: How to mock not installed npm package in jest? I am part of a project where new Module Federati

Mock smart contract solidity - can't deploy mock smart contract - TypeError: Contract "mockMyToken" should be marked as abstract

I wrote a smart contract that uses openzepplin ERC20 standard. I am able to deploy it using truffle and my tests work as expected. I am now trying to test part

Why can't dunder/magic methods be set in unittest.mock.Mock.configure_mock?

I was writing some unit test in python and needed to mock a very general collections.abc.Sized, so I set off creating a Mock with a __len__ method whose return

Why is my resetAllMocks not working in jest

The second expect(fs.writeFile).toHaveBeenCalledTimes(1) (in describe('Guid for MPX') returns an error because the writeFile has been called twice. In theory, j