Test component with "declare var"

In my angular2 application, I have a js file "connection.conf.js" with var:

var appTypeConf = "example-app"; 

The component uses the variable from "connection.conf.js":

 declare var appTypeConf: string; export class Component { public appType = appTypeConf; } 

It works in my application, but when I test the application with karma, I get an error message:

 ReferenceError: Can't find variable: appTypeConf (line 9) 

How to declare a variable in the component specification file?

+5
source share
1 answer

I found a solution, I had to add file.conf.js the path to the file array in the karma.conf.js file

 var files = [ // *** 'app/connection.conf.js' ] 
+8
source

Source: https://habr.com/ru/post/1261126/


All Articles