[英]karma +typescript + SystemJS — cache problems
Config: 配置:
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jspm', 'jasmine'],
files: [ /*all from jspm*/],
plugins: [
"karma-jspm",
'karma-jasmine',
'karma-chrome-launcher'
],
jspm: {
loadFiles: ['src/*.ts'], // here my tests are located
packages: "jspm/"
},
proxies: {
'/src/': '/base/src/', //to simplify /base url
'/jspm/': '/base/jspm/'
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
concurrency: Infinity
})
}
For example in "src" directory we have test1.ts
with test ... expect(true).toBe(false) ...
例如,在“ src”目录中,我们有带有测试的
test1.ts
... expect(true).toBe(false) ...
Karma starts and show that test is fail, OK 业障启动并显示测试失败,确定
Then i FIX test ... expect(true).toBe(true) ...
然后我修复测试
... expect(true).toBe(true) ...
Karma execute tests (so it watch changes), but... test still fail. 业力执行测试(因此它监视更改),但是...测试仍然失败。 When I open Chrome at 9876 i see that it loads 'test1.ts' and 'test1.ts!trsnpiled' by XHR (system.js works) but it's content is still unchanged, status of response - 200 (not 304), neither "disable cache" nor "Clean browser cache" don't helps.
当我在9876打开Chrome时,我看到它加载了XHR加载的“ test1.ts”和“ test1.ts!trsnpiled”(system.js正常运行),但其内容仍未更改,响应状态-200(不是304),两者均没有“禁用缓存”或“清除浏览器缓存”都无济于事。
I look at headers : Date changed initially it was Date:Tue, 01 Dec 2015 09:51:26 GMT and then Date:Tue, 01 Dec 2015 09:53:40 GMT (strange but mimetype for *.ts is video/mp2v while it's not for this issue) 我看标题:日期最初更改为Date:Tue,01 Dec 2015 09:51:26 GMT,然后Date:Tue,01 Dec 2015 09:53:40 GMT(很奇怪,但* .ts的mimetype是video / mp2v虽然不是为了这个问题)
But content - not - it's still old. 但是内容-不是-它仍然很旧。
Before i used typescript-preprocessor and native Karma module loader and where's not such problems but with system.js loader it occured, and i don't know who is responsible. 在我使用打字稿预处理器和本机Karma模块加载器之前,不是什么问题,但是在使用system.js加载器的情况下就发生了,我不知道是谁负责。
Then i restart karma it tests well. 然后,我重新启动业力,它测试得很好。
Have fix both problems (invalid mime and caching) in karma (mime) and karma-jspm (caching) source code, pull requests made to these teams - if someone has same problems - can look at 修复karma(mime)和karma-jspm(缓存)源代码中的两个问题(无效的mime和缓存),如果对这些团队有同样的问题,可以向这些团队提出请求拉取
https://github.com/Workiva/karma-jspm/pull/115 https://github.com/Workiva/karma-jspm/pull/115
https://github.com/karma-runner/karma/pull/1736 https://github.com/karma-runner/karma/pull/1736
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.