0
votes

I am trying to test my Angular project with Karma/Jasmine and the problem is that all the global modules that I am using are not recognized from spec., unless I add them in the test files as well.

Is there a way to test without importing every thing from scratch?

1

1 Answers

0
votes

In your angular.json file (might be called something slightly different if you are not using Angular v6) there is a test property with a scripts array underneath it. Mine looks like this:

"scripts": [
  "node_modules/jquery/dist/jquery.js",
  "node_modules/multiselect-two-sides/dist/js/multiselect.js"
]

Try throwing some stuff in there.

Note that in that file you will find 2 properties called scripts. One is for your regular environment and one for your test environment. Most likely, they should match pretty closely.