# "Cannot read property \_location of null" when testing with Jest and react-testing-library

**URL:** <https://community.apollographql.com/t/cannot-read-property-location-of-null-when-testing-with-jest-and-react-testing-library/7915>\
**Category:** Client SDKs\
**Tags:** client, web\
**Created:** [October 28, 2024, 1:48pm UTC](https://community.apollographql.com/t/cannot-read-property-location-of-null-when-testing-with-jest-and-react-testing-library/7915 "2024-10-28T13:48:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![boileroo](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/boileroo/32/5343_2.png) [@boileroo](https://community.apollographql.com/u/boileroo)\
**Post date:** [October 28, 2024, 1:48pm UTC](https://community.apollographql.com/t/cannot-read-property-location-of-null-when-testing-with-jest-and-react-testing-library/7915/1 "2024-10-28T13:48:18Z")

</div>

Hi,

I am encountering this issue intermittently but regularly when testing my NextJS React application using Jest and react-testing-library:

`"Cannot read property _location of null"`

This happens, I believe, because the Jest test process exits too quickly relative to what Apollo is doing, but I confess my understanding of this is a bit lacking.

I would appreciate any guidance on the issue and how I can resolve it! I can provide examples of my test setup if it would help.

Thank you

---

<div class="post-metadata">

**Author:** ![JeffAuriemma](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/jeffauriemma/32/2845_2.png) [@JeffAuriemma](https://community.apollographql.com/u/JeffAuriemma)\
**Post date:** [January 31, 2025, 4:45pm UTC](https://community.apollographql.com/t/cannot-read-property-location-of-null-when-testing-with-jest-and-react-testing-library/7915/2 "2025-01-31T16:45:40Z")

</div>

Hi @boileroo 👋 I don’t know enough to say what the issue might be, but your comment:

> This happens, I believe, because the Jest test process exits too quickly relative to what Apollo is doing

Makes me wonder if you have some unresolved promises that you’re not `await`ing in your test suite. Hope that helps!
