# damlReact.useQuery is not working for test cases

**URL:** <https://forum.canton.network/t/damlreact-usequery-is-not-working-for-test-cases/3687>\
**Category:** App Development\
**Created:** [January 10, 2022, 9:05am UTC](https://forum.canton.network/t/damlreact-usequery-is-not-working-for-test-cases/3687 "2022-01-10T09:05:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![priyanka](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@priyanka](https://forum.canton.network/u/priyanka)\
**Post date:** [January 10, 2022, 9:05am UTC](https://forum.canton.network/t/damlreact-usequery-is-not-working-for-test-cases/3687/1 "2022-01-10T09:05:40Z")

</div>

Hi Team,

We have recently upgraded our Daml version from 1.6.0 to 1.16.0.  
UseQuery is working fine functionality wise but we see some issue with our test cases.  
I am just giving structure of one test case where we are trying to use damlReact.useQuery

For eg -

damlReact.useQuery = jest.fn((template: any, argument, dependency) =\> {

```
  return {

    loading: false,

    contracts: []

  };

});

```

We get below error -  
TypeError: Cannot set property useQuery of [object Object] which has only a getter

Could you please help us to resolve this issue.

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [January 10, 2022, 9:21am UTC](https://forum.canton.network/t/damlreact-usequery-is-not-working-for-test-cases/3687/2 "2022-01-10T09:21:45Z")

</div>

Hi @priyanka, this looks like you’re probably running into [reactjs - TypeError during Jest's spyOn: Cannot set property getRequest of #\<Object\> which has only a getter - Stack Overflow](https://stackoverflow.com/questions/53162001/typeerror-during-jests-spyon-cannot-set-property-getrequest-of-object-which) or something very similar to that.

I’m not super familiar with jest but it looks like the most robust solution is to mock `@daml/react` completely rather than trying to override individual functions.

We do something similar in our own tests for mocking `@daml/ledger` [daml/index.test.ts at 1b23f91a92ee937b67673dd60d592f2bc98d9ac0 · digital-asset/daml · GitHub](https://github.com/digital-asset/daml/blob/1b23f91a92ee937b67673dd60d592f2bc98d9ac0/language-support/ts/daml-react/index.test.ts#L22)

---

<div class="post-metadata">

**Author:** ![priyanka](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@priyanka](https://forum.canton.network/u/priyanka)\
**Post date:** [January 12, 2022, 6:46am UTC](https://forum.canton.network/t/damlreact-usequery-is-not-working-for-test-cases/3687/3 "2022-01-12T06:46:19Z")

</div>

Thanks for your reply.  
Yes, issue was to related to mocking. I mocked data differently and it worked for me.
