karma runner - Injecting global javascript variable into a test in angular 4 -
i have global javascript variable defined in standalone js file, loaded in index.html <script type="text/javascript" src="./config/config.js"></script>
var testconfig = { apiurl: 'http://localhost:3000' };
and it's referenced in service as
declare let testconfig: any;
there're reasons doing way, instead of using environment files. because our ci process injects urls after ng build.
that's working fine when run application ng serve. i'm struggling past "testconfig not defined" error when running jasmine tests. adding config.js karma.conf.js has no effect.
karma.conf.js
files: [ { pattern: './src/config/config.js', watched: false}, { pattern: './src/test.ts', watched: false } ]
i can't see config.js being loaded @ in browser console though. wonder if that's mixture of javascript , typescript karma can't deal properly.
any suggestions?
Comments
Post a Comment