使用Yarn更新aurelia-dependency-injection
库之后,我在Jest测试中开始遇到以下错误。
似乎由于某种原因,依赖项注入库无法按预期工作?
● Datepicker › click date icon opens calendar
Loader must implement loadTemplate(url).
at Loader.loadTemplate (node_modules/aurelia-loader/dist/commonjs/aurelia-loader.js:119:11)
at ensureRegistryEntry (node_modules/aurelia-templating/dist/commonjs/aurelia-templating.js:3382:17)
at ViewEngine.loadViewFactory (node_modules/aurelia-templating/dist/commonjs/aurelia-templating.js:3456:12)
at RelativeViewStrategy.loadViewFactory (node_modules/aurelia-templating/dist/commonjs/aurelia-templating.js:562:23)
at HtmlBehaviorResource.load (node_modules/aurelia-templating/dist/commonjs/aurelia-templating.js:4238:27)
at ResourceDescription.load (node_modules/aurelia-templating/dist/commonjs/aurelia-templating.js:3258:26)
at ResourceModule.load (node_modules/aurelia-templating/dist/commonjs/aurelia-templating.js:3200:23)
at node_modules/aurelia-templating/dist/commonjs/aurelia-templating.js:3587:41
答案 0 :(得分:1)
问题是我的yarn.lock文件具有重复的aurelia-dependency-injection
引用:
aurelia-dependency-injection@^1.0.0, aurelia-dependency-injection@^1.3.1:
version "1.4.1"
resolved "https://private-yarn-mirror/aurelia-dependency-injection/-/aurelia-dependency-injection-1.4.1.tgz#fb916e1809446600fb2cdf062f549060df49ef86"
dependencies:
aurelia-metadata "^1.0.0"
aurelia-pal "^1.0.0"
aurelia-dependency-injection@^1.4.2:
version "1.4.2"
resolved "https://private-yarn-mirror/aurelia-dependency-injection/-/aurelia-dependency-injection-1.4.2.tgz#fa9d1a9f4931e353fb8f938ee0c54b9fbf3f341a"
dependencies:
aurelia-metadata "^1.0.0"
aurelia-pal "^1.0.0"
我的解决方案是简单地删除顶部引用,以使我的yarn.lock看起来像这样:
aurelia-dependency-injection@^1.4.2:
version "1.4.2"
resolved "https://private-yarn-mirror/aurelia-dependency-injection/-/aurelia-dependency-injection-1.4.2.tgz#fa9d1a9f4931e353fb8f938ee0c54b9fbf3f341a"
dependencies:
aurelia-metadata "^1.0.0"
aurelia-pal "^1.0.0"
然后我执行以下命令,以确保在手动编辑后yarn.lock将正确生成。
yarn add aurelia-framework@latest
这样做之后,我的yarn.lock看起来像这样:
aurelia-dependency-injection@^1.0.0, aurelia-dependency-injection@^1.3.1, aurelia-dependency-injection@^1.4.1, aurelia-dependency-injection@^1.4.2:
version "1.4.2"
resolved "https://private-yarn-mirror/aurelia-dependency-injection/-/aurelia-dependency-injection-1.4.2.tgz#fa9d1a9f4931e353fb8f938ee0c54b9fbf3f341a"
dependencies:
aurelia-metadata "^1.0.0"
aurelia-pal "^1.0.0"
现在我的Jest测试工作正常,其他地方也都可以正常工作。
此后不久,我发现了这篇文章,其中讨论了该问题,尽管我个人并没有使用那里的工具: