Reflect.getOwnMetadata is not a function in karma with latest Aurelia

血红的双手。 提交于 2019-12-12 18:30:47

问题


After updating to the latest version of Aurelia (March update beta.1.1.4), I'm getting the following error every time I run karma tests:

Error: Reflect.getOwnMetadata is not a function
Error loading C:/Software/myproject/test/unit/myclass.spec.ts

How do I fix it?


回答1:


This has to do with the change of Aurelia from core-js to home-grown polyfills. The Reflect polyfill is missing and tests fail to run.

This problem is addressed in Aurelia navigation skeleton app by the following import statement in each unit test file:

import 'aurelia-polyfills';

I solved it by creating a setup.ts (or setup.js resp. to your language) file with just this statement, and then just listing it in karma.config.js at the first place.

for JS e.g.:

jspm  : {
  loadFiles: ['test/unit/setup.js', 'test/unit/**/*.js'],
  ...
}

for Typescript e.g.:

files: ['test/unit/setup.ts', 'test/unit/**/*.ts'],
...


来源:https://stackoverflow.com/questions/35775200/reflect-getownmetadata-is-not-a-function-in-karma-with-latest-aurelia

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!