Category "unit-testing"

I modify response.data in Django REST Framework view.py. Why am I getting an AttributeError during testing but not with actual API use?

My Django REST Framework API is working just as expected. In view.py, I modify OrderViewSet, def partial_update, to add another key/value pair to the response.d

Unit testing useRouter's isReady

I have a component, which takes a parameter from the url and displays it. I implemented it using useRouter's isReady property. Something like this: import { use

JEST: My Isolated module function depends on a function found on the same module. After mocking, it still relies on the original implementation

I have abc.js const a = (a)=>{ return (b(a) + 1) } const b = (num)=>{ return(num + 1) } module.exports = { a, b } When I do my test for

Unusual Target Invocation Error in Unit Tests

I'm trying to run a group of 12 unit tests. When I run the entire group, one test passes and the rest fail with the same error: Could not find default endpoint

Is it bad practice to store/translate static error strings in a form field model?

I'm building a Flutter app where I have a sign-up form that will throw an error if the user inputs an invalid email. I have the following model for the email fo

How to Unit Test a method inside a module in NestJs (Jest)

I'm adding tests on a project and improving coverage. I would like to know how can I test a method defined inside a module definition in NestJs. import { Middle

Use DBUnit in Spring without defined entities via "nativequery"

I am trying to use DBunit while testing a Spring controller. The tests fail to initialize because my dataset contains tables/columns which are not defined by an

Can't add reference to System.Windows.Forms to .NET 5.0 Xunit unit test project

I have a solution in Visual Studio 2019 containing a WinForms .Net Framework 4.8 project and a .Net 5.0 test project. The WinForms project contains all my windo

Test functions cannot both take a 'done' callback

I'm trying to create a simple test with nestjs, and I'm get this error Test functions cannot both take a 'done' callback and return something. Either use a 'do

test class for handler trigger is not covered

I did a trigger on content version ,but my handler class is not covered ,can you please explain to me why ? please find below the code and screenshots for non c

can we mock method inside object

object Abc { method1(param1,param2):Future[Option[String]] = { //some work } } We are using method1 somewhere and need to stub method1 how can

PYTEST - Is it possible to create the same fixtures more than one time?

I have some parameters coming from a JSON file, and some fixtures in my conftest.py I would like to iterate all the option scenarios from my list and create my

It looks like '' has not been IVY compiled - it has no 'ɵcmp' field

I am currently using Angular 11. When I run the unit tests, all pass except one which says: Error: It looks like 'ResultsService' has not been IVY compiled - it

Identifier "Return" is undefined in gtest?

SPIGtestMain.cpp #include "gtest/gtest.h" #include "gmock/gmock.h" TEST_F(GivenANewSPI,WhenDemoIsCalled_TheComponentGetsVal) { unsigned char const *Ptr;

How to test MassTransit saga state machine with certain state?

I have state machine build with MassTransit: public class OrderStateMachine : MassTransitStateMachine<Order> { public State Completed { get; init; }

Unit Testing - How to build tests around domain entities with lots of encapsulation and many internal states

Admittedly, very new to Unit Testing right now but I'm wanting to make sure I don't end up with a testing project that ends up being a nightmare to maintain. Th

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

Hypothesis library: strategy for the complement of some other strategy

I'm using the Hypothesis library for unit testing. With this library you don't hand-pick inputs, but you define the complete set of inputs for which you want to

How to jest.mock an ES6 module import?

I've moved a load of helper methods into a npm published library, but some of them are being mocked in the unit tests and I can't figure out how to mock the new