这里用开玩笑测试的地图抛出InvalidArgumentError:H.UTIL.CACHE#SETMAXSIZE

发布于 2025-02-09 12:27:39 字数 1189 浏览 1 评论 0原文

我正在尝试在React中测试我的此处地图组件。我的设置非常紧密地遵循指南。一切都在生产中效果很好。我正在使用babel转换JS软件包@tere/maps-api-for-javascript

运行测试时,我会收到此错误:

InvalidArgumentError: H.util.Cache#setMaxSize (Argument #0 0)

      34 |     })
      35 |     const layers = platform.createDefaultLayers()
    > 36 |     const map = new H.Map(ref.current, layers.vector.normal.map, {
         |                 ^
      37 |       pixelRatio: window.devicePixelRatio || 1,
      38 |       center: { lat: 6.6111, lng: 20.9394 },
      39 |       zoom: 5

我的jest.config.js如下:

{
  "bail": true,
  "collectCoverageFrom": ["**/src/**/*.ts?(x)", "!**/src/index.tsx"],
  "moduleNameMapper": {
    "\\.(css|less|scss)$": "identity-obj-proxy"
  },
  "verbose": true,
  "preset": "ts-jest",
  "setupFiles": ["./scripts/env-setup.ts"],
  "setupFilesAfterEnv": ["./scripts/jest.setup.ts", "jest-canvas-mock"],
  "testMatch": ["**/src/**/*.test.ts?(x)"],
  "transformIgnorePatterns": ["/node_modules/(?!(@here|bar)/)"],
  "transform": { "^.+\\.js?$": "babel-jest" }
}

测试与Expect(MapWrapper).tobetruthy()

不确定在哪里要开始调试这个。有什么建议吗?

I'm trying to test my Here Map component in React. My setup follows the guide pretty closely. Everything works fine in production. I'm using babel to transform the JS package @here/maps-api-for-javascript.

When running my tests I get this error:

InvalidArgumentError: H.util.Cache#setMaxSize (Argument #0 0)

      34 |     })
      35 |     const layers = platform.createDefaultLayers()
    > 36 |     const map = new H.Map(ref.current, layers.vector.normal.map, {
         |                 ^
      37 |       pixelRatio: window.devicePixelRatio || 1,
      38 |       center: { lat: 6.6111, lng: 20.9394 },
      39 |       zoom: 5

My jest.config.js is as follows:

{
  "bail": true,
  "collectCoverageFrom": ["**/src/**/*.ts?(x)", "!**/src/index.tsx"],
  "moduleNameMapper": {
    "\\.(css|less|scss)
quot;: "identity-obj-proxy"
  },
  "verbose": true,
  "preset": "ts-jest",
  "setupFiles": ["./scripts/env-setup.ts"],
  "setupFilesAfterEnv": ["./scripts/jest.setup.ts", "jest-canvas-mock"],
  "testMatch": ["**/src/**/*.test.ts?(x)"],
  "transformIgnorePatterns": ["/node_modules/(?!(@here|bar)/)"],
  "transform": { "^.+\\.js?
quot;: "babel-jest" }
}

The test is as simple as expect(mapWrapper).toBeTruthy()

Not sure where to start debugging this. Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城花音 2025-02-16 12:27:39

您没有将正值传递给新的H.Util.Cache方法,这就是为什么它会抛出错误的原因。

缓存表示具有固定尺寸的内存中LRU-CACHE。一旦在缓存中保存的元素达到最大允许的大小,缓存就会以最古老的检索时间戳下降元素,以使缓存数据的大小在边界内。缓存中保存的数据元素具有其ID和大小以促进检索。

名称类型说明
最大数字
最大大小的值

一个表示缓存opt_ondrop函数(字符串,?,number)
删除数据元素时,要调用回调

从CACHE OPT_FILTER函数
要过滤的数据元素

以获取更多详细信息,请检查指南

You are not passing the positive values to the new H.util.Cache method, That is why it is throwing error.

The cache represents an in-memory LRU-cache with a fixed size. Once the elements held in the cache reach the maximum permitted size, the cache drops the elements with the oldest retrieval time stamp to bring the size of the cached data within bounds. Data elements held in the cache are stored with their IDs and size to facilitate retrieval.

Name Type Description
maxSize number
A value indicating the maximum size of the cache

opt_onDrop function(string, ?, number) optional
A callback to be invoked when a data element is dropped from the cache

opt_filter function optional
A function to filter data elements that are not to be cached

For more details, please check the GUIDE

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文