Thursday, October 12, 2017

Can’t Find JQuery When Running ‘ng test’ Command

I have created a project using new angular-cli version and I made the project up and running. When I run ng serve and ng build command it works perfectly without giving any errors. But when I tried to run ng test it shows me errors like this.

theme.provider.ts (53,31): Property 'removeClass' does not exist on type 'JQuery'.
theme.provider.ts (64,35): Property 'addClass' does not exist on type 'JQuery'.
theme.provider.spec.ts (7,30): Cannot find name '$'.

I have added JQuery in the following way to the angular-cli.json

"scripts": [
    "../node_modules/jquery/dist/jquery.min.js"
 ],

Then I have imported JQuery to my main module via this way

import 'jquery';

Are there any missing steps in the above configurations?

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/10/12/cant-find-jquery-when-running-ng-test-command/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment