31 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
0
answers
61
views
test case throwing error - TypeError: Cannot read properties of undefined (reading 'subscribe')
I am getting error "TypeError: Cannot read properties of undefined (reading 'subscribe')".
Below is the report.service.ts code
saveReport(reportData: any, reportType: string, reportId: ...
1
vote
1
answer
287
views
Why doesn't my ts-mockito spy delegate method calls?
I have a simple class called MyPresenter with a doOperation() method that calls one method on a View class that implements an interface and is passed in as a parameter. Here's the class, the interface ...
0
votes
1
answer
522
views
ts-mockito: When mocking a function named `execute`, I get "execute is not a function"
I am testing a typescript project with ts-mockito and jest. Getting errors like this on a function called execute:
Error: 'MyAbstractClass.execute' is not a function
// main.ts
abstract class ...
2
votes
1
answer
219
views
How to mock mysql2 `getConnection`
I can't properly mock getConnection method from pool in mysql2 lib. My setup is next:
"ts-mockito": "^2.6.1"
"typescript": "^4.8.4"
"mocha": "^10....
1
vote
1
answer
2k
views
Issues mocking objects in Typescript with ts-mockito
When I try to use mockito-ts to mock the return value of member functions on instances of mocked objects, I get that the member function is not a function.
TypeError: Cannot read properties of null (...
1
vote
1
answer
724
views
Verify setter has been called in ts-mockito
Location is defined as follows:
interface Location {
...
search: string;
...
}
Let's say I have a service that looks like this:
export class MyService {
constructor(private readonly ...
1
vote
0
answers
470
views
How to mock ClientProxy microservice for nestjs in ava test framework
I am trying to give the mock data in ClientProxy but I am keep on receiving null. It could be because of returning Observable. But I cannot figure it out how to properly mock the result.
I am using ...
0
votes
1
answer
166
views
Why do I get an AssertionError: expected MethodToStub on mocking a method returning a promise
On entering a world of MEAN, I am also entering a world of promises.
Now I got this problem:
const promise = new Promise<Boolean>(() => {});
const testObject = mock(DB_DAO_object);
when (...
0
votes
2
answers
846
views
How to mock a named nestjs Logger with ts-mockito
Our project uses nestjs with mocha, chai and ts-mockito for testing and I can't figure out how to test a named nestjs Logger.
new Logger() can be tested as expected:
describe('basic test', () => {
...
0
votes
1
answer
2k
views
How to mock imported function in ts-mock
I'm new to typescript and playing around with aws-lambda.
I'm trying to unit test my handler so I need to mock the service class so it will return some mocked data
Below I have a simple function that ...
4
votes
1
answer
857
views
mock transaction in runTransaction
i want to mock code inside a runTransaction function.
example code:
await admin.firestore().runTransaction(async transaction => {
const hubDocument = admin.firestore().collection("Acme")...
1
vote
1
answer
641
views
How to test await toPromise() inside async function? (.toPromise() is not a function error)
Based on this question, I wrote this test:
it('call service when search product by code', async() => {
let code: string = 'CODE';
let product: Product = createProduct();
let properties: ...
1
vote
1
answer
168
views
Mocked service does not disable button in angular test?
I am using angular material stepper to navigate in my component have the below button:
Below is my stepper.component.html code
<button [disabled]="myService.disableNextButton(stepper....
-1
votes
1
answer
111
views
How can i supress Api error and return a value instead?
I get a 404 for unused and a 204 for used email from my API. Now i want to transform that to boolean (true/false) using rxjs/pipe and catchError.
emailAvailable(): Observable<boolean> {
return ...
1
vote
1
answer
796
views
Mock WebAPI interface using ts-mockito
I'm writing a unit test for a class which uses browser WebAPI interface.
I use ts-mockito to mock the interface (a WebGL2RenderingContext in my case).
When I run the test, Node throws ReferenceError: ...