I am trying to update an Angular 2 project by implementing the changes indicated in the official Angular 2 change log.
我试图通过实施官方Angular 2更改日志中指示的更改来更新Angular 2项目。
(If you care to know the details, I completely worked through a tutorial that was built with Angular 2 version 2.0.0-beta.13 and want to now convert it to the current latest Angular, i.e. version 2.0.0-rc.6. The tutorial itself can be found on Youtube and the final code can be found on GitHub.)
(如果您想了解详细信息,我完全使用了使用Angular 2版本2.0.0-beta.13构建的教程,并希望现在将其转换为当前最新的Angular,即版本2.0.0-rc.6教程本身可以在Youtube上找到,最终的代码可以在GitHub上找到。)
I'm stuck at the following step: The change log for Angular 2 version 2.0.0-beta.16 states the following:
我坚持以下步骤:Angular 2版本2.0.0-beta.16的更改日志指出以下内容:
You will also need to add the dependency 'node_modules/zone.js/dist/fake-async-test.js' as a served file in your Karma or other test configuration.
您还需要在Karma或其他测试配置中将依赖项“node_modules / zone.js / dist / fake-async-test.js”添加为服务文件。
I'm not sure I completely understand what that means, and I don't see an obvious way to implement it. The karma.conf.js
file for this project is the following:
我不确定我完全理解这意味着什么,我没有看到明显的方法来实现它。该项目的karma.conf.js文件如下:
// Karma configuration
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['browserify', 'source-map-support', 'jasmine'],
// list of files / patterns to load in the browser
files: [
'test/init.js',
'src/**/*.spec.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/init.js': ['browserify'],
'src/**/*.spec.js': ['browserify']
},
browserify: {
debug: true,
transform: ['babelify']
},
specReporter: {
maxLogLines: 5,
suppressErrorSummary: true,
suppressFailed: false,
suppressPassed: false,
suppressSkipped: true,
showSpecTiming: true
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['spec'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultanous
concurrency: Infinity
})
};
I suspect the solution will involve a change to the above karma.conf.js
file, but also possibly installation of an npm package, either through a command line npm install ...
or, more likely, through modifying the dependencies in package.json
. I don't know if this is relevant, but the tutorial's original (i.e. Ang2-beta.13) package.json
lists zone.js ^0.6.6
as a dependency while the change log for the most recent Angular2 (rc.6) lists zone.js ^0.6.17
in its peer dependency updates.
我怀疑解决方案将涉及更改上面的karma.conf.js文件,但也可能通过命令行npm install安装npm包...或者更可能通过修改package.json中的依赖项。我不知道这是否相关,但教程的原始(即Ang2-beta.13)package.json列出了zone.js ^ 0.6.6作为依赖,而最近的Angular2的更改日志(rc.6)在其对等依赖项更新中列出zone.js ^ 0.6.17。
Where have I looked? Well, I don't see an obvious place in this pre-existing config file for this new dependency to go, so I suspect that it might involve a configuration property not previously needed for this project. The questions asked by karma init
seem too basic to be relevant. I have looked over the complete list of karma configuration options and don't see an obvious place for this (and that page doesn't even contain the words "dependency" or "served"). I have also looked over the official Karma documentation for files and plugins and neither provide an obvious solution.
我在哪里看?好吧,我没有在这个预先存在的配置文件中看到这个新依赖项的明显位置,所以我怀疑它可能涉及此项目以前不需要的配置属性。 karma init提出的问题似乎过于基本无关。我查看了完整的业力配置选项列表,但没有看到明显的位置(该页面甚至不包含“依赖”或“服务”字样)。我还查看了文件和插件的官方Karma文档,但都没有提供明显的解决方案。
So, how do I do what the change log mandates, i.e. how do I "add the dependency 'node_modules/zone.js/dist/fake-async-test.js' as a served file in [my] Karma ... configuration"?
那么,我该如何处理更改日志所要求的内容,即如何在[my] Karma ...配置中将“依赖关系'node_modules / zone.js / dist / fake-async-test.js'添加为服务文件” “?
1 个解决方案
#1
0
It turns out that the answer is probably embedded in the change log for version rc.6. There, they state the following under "Breaking Changes": "testing config: due to zone.js peer-dependency upgrade, the order in which various zone specs are loaded has changed. Please see this example Karma config." That example karma config shows the following:
事实证明,答案可能已嵌入到版本rc.6的更改日志中。在那里,他们在“Breaking Changes”中声明了以下内容:“测试配置:由于zone.js对等依赖性升级,加载各种区域规范的顺序已经改变。请参阅此示例Karma配置。”该示例karma配置显示以下内容:
config.set({
files: [
...,
// Reflect and Zone.js
'node_modules/reflect-metadata/Reflect.js',
'node_modules/zone.js/dist/zone.js',
'node_modules/zone.js/dist/long-stack-trace-zone.js',
'node_modules/zone.js/dist/proxy.js',
'node_modules/zone.js/dist/sync-test.js',
'node_modules/zone.js/dist/jasmine-patch.js',
'node_modules/zone.js/dist/async-test.js',
'node_modules/zone.js/dist/fake-async-test.js',
...
],
...
});
I don't yet know how much of that list of dependencies is relevant, but at least it shows the syntax for including fake-async-test.js
.
我还不知道有多少依赖项是相关的,但至少它显示了包含fake-async-test.js的语法。
That's probably the best answer to my specific question. However, more generally, the linked example karma config file from the change log for version rc.6 is probably going to go a long way to helping me do the overall project update.
这可能是我特定问题的最佳答案。但是,更一般地说,版本rc.6的更改日志中的链接示例karma配置文件可能会帮助我完成整个项目更新。
#1
0
It turns out that the answer is probably embedded in the change log for version rc.6. There, they state the following under "Breaking Changes": "testing config: due to zone.js peer-dependency upgrade, the order in which various zone specs are loaded has changed. Please see this example Karma config." That example karma config shows the following:
事实证明,答案可能已嵌入到版本rc.6的更改日志中。在那里,他们在“Breaking Changes”中声明了以下内容:“测试配置:由于zone.js对等依赖性升级,加载各种区域规范的顺序已经改变。请参阅此示例Karma配置。”该示例karma配置显示以下内容:
config.set({
files: [
...,
// Reflect and Zone.js
'node_modules/reflect-metadata/Reflect.js',
'node_modules/zone.js/dist/zone.js',
'node_modules/zone.js/dist/long-stack-trace-zone.js',
'node_modules/zone.js/dist/proxy.js',
'node_modules/zone.js/dist/sync-test.js',
'node_modules/zone.js/dist/jasmine-patch.js',
'node_modules/zone.js/dist/async-test.js',
'node_modules/zone.js/dist/fake-async-test.js',
...
],
...
});
I don't yet know how much of that list of dependencies is relevant, but at least it shows the syntax for including fake-async-test.js
.
我还不知道有多少依赖项是相关的,但至少它显示了包含fake-async-test.js的语法。
That's probably the best answer to my specific question. However, more generally, the linked example karma config file from the change log for version rc.6 is probably going to go a long way to helping me do the overall project update.
这可能是我特定问题的最佳答案。但是,更一般地说,版本rc.6的更改日志中的链接示例karma配置文件可能会帮助我完成整个项目更新。