GithubHelp home page GithubHelp logo

Comments (7)

webmapLee avatar webmapLee commented on June 11, 2024

it can't work when use aysnc/await,but loadModules return a Promise...

from esri-loader.

andygup avatar andygup commented on June 11, 2024

Hi @webmapLee you'll need to provide a simple github repo that reproduces the problem. This looks like you are mixing ES modules from @arcgis/core with our ArcGIS CDN, which uses AMD modules, along with TypeScript types from arcgis-js-api. Note that combining ESM with AMD modules within a single application won't work. https://developers.arcgis.com/javascript/latest/tooling-intro/#compare-amd-and-es-modules.

I'm not sure what framework you are using, but here's a Angular/TypeScript/Jest example using @arcgis/core: https://github.com/andygup/angular-jsapi-jest

from esri-loader.

webmapLee avatar webmapLee commented on June 11, 2024

now i can run esri-loader/loadModules test case with jest, but i can only use it like this:

test('arcgis 模块调用', () => {
    arcgisApiRequests(['esri/Map']).then((loadedModules) => {
        console.log(loadedModules)
    })
  })

i can't use async await,like this:

test('arcgis 模块调用', async () => {
    const [Map] = arcgisApiRequests(['esri/Map'])
    console.log(Map)
  })

from esri-loader.

nel11211 avatar nel11211 commented on June 11, 2024

I don't know if this is the same, but on ArcGIS Charts we get the following error running jest:
TypeError: utils.Promise is not a constructor.

I believe it is happening because of this line in the esri-loader repo.

Which only uses window['Promise'] when running in the browser, otherwise the utils.Promise is set to undefined, which results in the type error seen above.

Is there workaround available on our end, or any way this could be changed on your end to allow using esri-loader with jest?

from esri-loader.

andygup avatar andygup commented on June 11, 2024

@nel11211 we'll need a repro case. I'm not familiar with ArcGIS Charts, are they running the latest version of the ArcGIS JS API?

from esri-loader.

nel11211 avatar nel11211 commented on June 11, 2024

@nel11211 we'll need a repro case. I'm not familiar with ArcGIS Charts, are they running the latest version of the ArcGIS JS API?

We are using arcgis-js-api@next (version is 4.23.0-next.20220316), and esri-loader version 3.3.0. The simplest description of our repro is something like this:

  • Set up a Jest unit test that imports loadModules from esri-loader and calls await loadModules(...) at some point.
  • Run the unit test in Jest, throws error: TypeError: utils.Promise is not a constructor.

from esri-loader.

andygup avatar andygup commented on June 11, 2024

Closing.

from esri-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.