Comments (7)
it can't work when use aysnc/await,but loadModules return a Promise...
from esri-loader.
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.
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.
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.
@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 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
fromesri-loader
and callsawait loadModules(...)
at some point. - Run the unit test in Jest, throws error:
TypeError: utils.Promise is not a constructor
.
from esri-loader.
Closing.
from esri-loader.
Related Issues (20)
- drop IE support? HOT 2
- ArcGIS JS API 4.18 Sketch Widget graphics and graphic selection often do not render in Angular 11 application HOT 4
- angular esri-loader 4.18 graphics refresh bug HOT 4
- Sketch widget: graphics not visible HOT 2
- new `esri-loader-typings-helper` plugin for VS Code HOT 2
- esri-loader dojoConfig removed not able to set has: {"csp-restrictions": true} HOT 2
- isLoaded or ready prop? HOT 2
- switch release process over to use np HOT 1
- Is it possible to have crossorigin attribute when loading ArcGIS modules? HOT 8
- Clean up dependabot PRs HOT 1
- 利用BaseTileLayer.createSubclass进行扩展,读取离线tms瓦片。 HOT 3
- Esri sources don't get loaded from our server HOT 3
- wall o compile node_module/@types errors when you run tests HOT 2
- ERROR ReferenceError: Can't find variable: document HOT 2
- After upgrading ESRI/Loader from 2.5.0 to 3.6, Querytask.js library file is returning 404 error HOT 2
- Update product name in error messages at 4.26 HOT 3
- Are you using esri-loader with Angular and Zone.js?
- What is the latest version that supports Angular 14 and ESRI JS API v3.x? HOT 2
- How to change the default Map Language ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esri-loader.