问题
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