Select to view content in your preferred language

esriRequest returning error in test file

542
0
08-30-2023 03:54 AM
HamzaAmdouni
New Contributor

I'm currently facing an issue when trying to run my tests in my vue3 project, the fetch is running normally without any issues but the tests are failing for unknown reason, I have found a similar issue but I'm using a different version than that: https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/why-is-esrirequest-not-working/td...

Current lib versions:
vue: v3.2

@ArcGIS/core v4.27.5

vitest v0.24.3

This is my function which I'm getting the error from:

  const fetchAddressReverse = async (lng, lat) => {
    const apiRequest = await esriRequest(searchApiCredentials.esriSearchUrl, {
      query: {
        token: directionsApiCredentials.esriToken,
        f: 'json',
        location: `${lat},${lng}`,
      },
    })
    if (!apiRequest || !apiRequest.data?.address || !apiRequest.data.address?.LongLabel) return null
    return transformAddress(apiRequest.data.address?.LongLabel)
  }

 

And when I run my tests I'm getting this error:

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: Right-hand side of 'instanceof' is not an object
 ❯ K node_modules/@arcgis/core/request.js:5:3388
 ❯ V node_modules/@arcgis/core/request.js:5:8091
 ❯ Proxy.j node_modules/@arcgis/core/request.js:5:2032
 ❯ Object.fetchAddressReverse src/service/external/geo/useGeoService.ts:84:23
     82|    */
     83|   const fetchAddressReverse = async (lng, lat) => {
     84|     const apiRequest = await esriRequest(searchApiCredentials.esriSearchUrl, {
       |                       ^
     85|       query: {
     86|         token: directionsApiCredentials.esriToken,

 

 

Tags (3)
0 Kudos
0 Replies