Reflect.getOwnMetadata不是最新Aurelia的业力函数 [英] Reflect.getOwnMetadata is not a function in karma with latest Aurelia

查看:156
本文介绍了Reflect.getOwnMetadata不是最新Aurelia的业力函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新到最新版本的Aurelia(3月更新beta.1.1.4)之后,每次运行业力测试时都会遇到以下错误:

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

我该如何解决?

推荐答案

这与将Aurelia从core-js更改为本地的polyfill有关.缺少反射"填充并且测试无法运行.

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.

在Aurelia导航框架应用程序中,通过每个单元测试文件中的以下import语句解决了此问题:

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

import 'aurelia-polyfills';

我通过仅使用此语句创建一个setup.ts(或setup.js对应于您的语言的)文件,然后将其首先列在karma.config.js中来解决了该问题.

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.

对于JS例如:

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

对于打字稿,例如:

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

这篇关于Reflect.getOwnMetadata不是最新Aurelia的业力函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆