Category "unit-testing"

(Apollo client v3) useLazyQuery custom hook testing

I was struggling with a test issue for my custom useLazyQuery hook. My first test is passing but the second one is failing. What am doing wrong for the second t

How can I use jest to spyOn an internal function?

2 questions in 1 here. Why do I get an error message for my jest.spyOn saying that createMappingsDirectory is not a function? Secondly, I think where I’ve

How to mock axios.create([config]) function to return its instance methods instead of overriding them with mock?

I'm trying to mock axios.create() because I'm using its instance across the app and obviously need all of its implementation which is destroyed by the mock, thu

LNK2005 linkage error when running c++ unit test

I am relatively new to c++ and I am not sure how I can resolve this error. I have a namespace QueryUtils which I am including it into another class QuerySyntaxP

PyCharm: individually working tests, not finding a file when run in group

In my Python project, I have a set of unittests, that load some data from files in a data sub-directory. In PyCharm (Community 2019.3), running each of them in

Why is caplog.text empty, even though the function I'm testing is logging?

I'm trying to use pytest to test if my function is logging the expected text, such as addressed this question (the pyunit equivalent would be assertLogs). Foll

Django Rest Framework gives 302 in Unit tests when force_login() on detail view?

I'm using Django Rest Framework to serve an API. I've got a couple tests which work great. To do a post the user needs to be logged in and I also do some checks

Application controls are getting identified differently by CodedUi Test Builder

I am not able to Identify correct control of an application by Coded Ui Test Builder Seee this Image

Specflow is not executing tests in Visual Studio 2019

I have a very weird behavior with Specflow that only applies to one team member. Everyone else have no issue what so ever. The VS2019 testrunner is correctly d

How do I mock boto3's StreamingBody object for processing with BytesIO in Python?

I'm unittesting a function that transforms an element from an S3 object into a pandas DataFrame and need to mock the returned StreamingBody object from boto3 f

Failed to load module 'project name'

I added unit test target to my existing project, but while @testable import Product_Module_Name getting error "Failed to load module 'Product_Module_Name'". I

Missing required module 'Firebase' for Unit test

i added Unit test target to existing project, when i @testable import Product_Module_Name in test class i am getting Missing required module 'Firebase' i am u

Error :StreamJsonRpc.ConnectionLostException: The JSON-RPC connection with the remote party was lost before the request could complete

My unit tests disappear from TestExplorer of visual Studio 2019 16.3.5 The output from test engine is: [16/10/2019 6:45:48.705 Error] StreamJsonRpc.Connectio

Svelte - Not able to fetch data from JSON file during jest unit testing

During unit testing, I am getting undefined error, while executing svelte component with json file. Restaurant.svelte : import data from '../Data/restaurants.js

Jest messageParent can only be used inside a worker

Is there a way to get a proper error message? when i do $npm test and I intentionally break my code(cough cough remove a line of code) I get this message src/re

In Corda flow tests, how to get the modularized cordapps assigned only to the respective parties?

As per the Corda coding guidelines, I have seperated out modules into contracts and workflows-common. There are workflows modules like workflows-party1, workflo

Trying to mock an http client that is inside a controller, using phpunit, but it doesn't work

I have to test the routes of a controller which uses Guzzle Wrapper as a client to get data from an API. The app uses Laravel as a framework. This is the part o

In Dart, how to verify a void method that does not throw exception in unit tests?

I am implementing some data verification library in Dart. The validating method has void return type and throws exceptions on errors. The code below shows an ex

DRF/Multi-tenant - How to specify tenant host (domain) in unit tests?

Environment - Django, Rest Framework, Multi-tenant. In my unit tests, I'm trying to hit an endpoint in a tenant schema (not in Public). It is failing because

Angular karma code coverage report folder not generated

When I run ng test --code-coverage, The coverage report is sometimes not generating, sometimes it is generating so I'm unable to verify the coverage statement a