问题描述
我无法将业力配置为代理网站根目录中的文件。我的一个角度组件包含一个嵌入式Ace编辑器,该编辑器在http:// localhost:9876 / worker-html.js中查找文件。我已经使用files属性成功地在Karma中提供了文件
// Makes ace files available in tests
files: [
{ pattern: "../node_modules/ace-builds/src-min-noconflict/worker-html.js",watched: false,included:false,nocache:false,served:true }
],
并验证它是否已提供(通过检查window .__ karma__,它并不总是在karma浏览器窗口中定义,我不知道为什么,但这是一个单独的问题)。我还验证了可以在以下路径访问所需文件:
http://localhost:9876/absoluteD:/Evan/programming%20stuff/Projects/Gneus/node_modules/ace-builds/src-min-noconflict/worker-html.js
但是,我终生无法将其代理到所需的URL(http:// localhost:9876 / worker-html.js)。我已经尝试了我能想到的所有合理的代理配置,所以我认为我缺少一些基本知识。有人可以帮我吗?以下是整个业力配置文件供参考,其中包括我的最新代理尝试:
// Karma configuration file,see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',frameworks: ['jasmine','@angular-devkit/build-angular'],plugins: [
require('karma-jasmine'),require('karma-chrome-launcher'),require('karma-jasmine-html-reporter'),require('karma-coverage-istanbul-reporter'),require('@angular-devkit/build-angular/plugins/karma')
],client: {
clearContext: false,// leave Jasmine Spec Runner output visible in browser
// Don't run tests in random order
// If you update this,you have to restart ng test batch
jasmine: {
random: false
}
},// Makes ace files available in tests
files: [
{ pattern: "../node_modules/ace-builds/src-min-noconflict/worker-html.js",served:true }
],proxies: {
'/worker-html.js': "http://localhost:9876/absoluteD:/Evan/programming stuff/Gneus/node_modules/ace-builds/src-min-noconflict/worker-html.js"
},coverageIstanbulReporter: {
dir: require('path').join(__dirname,'../coverage'),reports: ['html','lcovonly'],fixWebpackSourcePaths: true
},reporters: ['progress','kjhtml'],port: 9876,colors: true,logLevel: config.LOG_INFO,autoWatch: true,browsers: ['Chrome'],singleRun: false,});
};
解决方法
上面评论(dev.to/jwp/angular-karma-proxy-configuration-1kbb)中John的链接将我带到了正确的代理配置。我的问题有两个方面:我不理解代理对象的各个部分,并且复制的链接(经典)有误。这是工作配置文件的相关部分,适用于可能会帮助您的人:
@Module
abstract class MyDaggerModule {
@Binds
abstract fun provideSomething(somethingImpl: SomethingImpl): Something
companion object {
@Provides
fun provideAnotherThing(): AnotherThing {
return AnotherThing()
}
}
}