Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test component with "declare var"

In my angular2 app I have js file "connection.conf.js" with var:

var appTypeConf = "example-app";

Component uses the variable from "connection.conf.js":

declare var appTypeConf: string;

export class Component {
  public appType = appTypeConf;
}

it works corectly in my app, but when I test application with karma, I receive a error:

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

How to corectly declare a variable in the component spec file?

like image 532
Emerceen Avatar asked Dec 12 '16 10:12

Emerceen


1 Answers

I found the solution, I had to add connection.conf.js path to files array in karma.conf.js

var files = [
  // ***
  'app/connection.conf.js'
]
like image 150
Emerceen Avatar answered Oct 19 '22 04:10

Emerceen