122 questions
0
votes
1
answer
301
views
vi.spyOn(reactRedux, 'useDispatch') is not working / "TypeError: Cannot redefine property: useDispatch"
I don't seem to find a solution for the below code / test to work (I went through a lot of articles and stackOverflow...). Various solutions provided by chatGPT are useless as well. I also see people ...
-1
votes
1
answer
288
views
Does spyOn(console, 'log') check all the output? Did I find a bug?
In my console, I see this:
console.log
27 (>$-1 not safe, so NOT) buying 0.6573442493668066 XBTUSD at 62777 with leverage none to close at 63718.7 as 1747062777
My test code says:
await bot....
0
votes
1
answer
954
views
Mocking TranslationService in Angular
I'm new in using Karma and unit tests in Angular and I'm struggling...
I have a method I want to test when the service I'm using is returning a bad request
The method is
this._commandService....
1
vote
1
answer
124
views
Angular Mocking Service with multiple signature
In my Angular project, all the Rest services are defined like below, they have 4 signatures
public commandsGet(oem: string, countryCode?: string, observe?: 'body', reportProgress?: boolean): ...
1
vote
0
answers
89
views
Jasmine Spy of Function inside Function async
I have a function (functionUnderTest) that calls another function (functionToTest). Both return an observable.
I want to test if the function functionToTest is called when functionUnderTest is called. ...
0
votes
1
answer
53
views
Running several Jest tests when spying the same prototype function
I have some code similar to this:
class A {
f1() { }
}
function f2() {
const a = new A();
a.f1();
}
test('test1', async () => {
const spy_f1 = jest.spyOn(A.prototype, "f1")...
0
votes
1
answer
323
views
spyOn and createSpyObj in the same spec jasmine
I'm using Jasmine to test this
class X{
test(obj){
return obj.someFunction()+100
}
}
so my spec is
it("test if someFunction is called and return value calculated correctly",()=>{...
0
votes
0
answers
44
views
Jasmine spyOn never been called due to multitone service
Here's my component:
export class QrcodeComponent implements OnInit {
constructor(
private qrGenService: QrGeneratorService,
) {
}
private draw(): void {
this.setOptions();
this....
1
vote
2
answers
1k
views
jest.spyOn looks like its sharing context across multiple tests (in the same describe)
When I just run my individual test it works. When I run the whole file I get this error.
Let's say I have an entity called Group, Group has properties and methods. I'm trying to verify that these ...
1
vote
1
answer
1k
views
Mocking side effect function with Vitest
Not sure how I can mock a side-effect function with Vitest in Typescript Node.js project, Vitest 0.33.0. Consider this simplified example:
// dummy.ts
export function parent(): string {
return `foo${...
3
votes
0
answers
1k
views
VITEST VUE SCRIPT SETUP: How to test if a method is called inside onMounted
How can you test if a method is called inside the onmount in vue with script setup.
The problem is that there is documentation that is done with option api where in the test I can call the component ...
1
vote
1
answer
1k
views
Error with SpyObj how to reassign the value of spy
I'm fairly new to Jasmine so excuse my silly question.
I'm trying to override the value of the spy only for one it block and I'm hitting issues.
I'm seeing ERROR: <spyOn> : ActionsEnabled has ...
5
votes
1
answer
4k
views
vitest vi.spyOn does not work on side effects?
I would like to use `vi.spyOn` to monitor the call to an sideEffect function
in a module to make sure is being called by another function in a module.
I did this on jest without problems but it does ...
0
votes
1
answer
944
views
How can I spy on a function that is returned by a other function with Jest spyOn
I wonder why the last assert (expect(msgSpy).toBeCalled()) in this example fails. What do I need to change to make it pass?
it('spyOn test', () => {
const newClient = () => {
const ...
0
votes
1
answer
268
views
how to use spyon on Matdialog in angular test case
In my test case, I am trying use spyon and call the dialog,
but it still says 'Statement not covered' in the coverage report in the line where we are opening the dialog(this._dialog.open(...