{"id":3854,"date":"2020-07-12T16:55:14","date_gmt":"2020-07-12T16:55:14","guid":{"rendered":"https:\/\/codethataint.com\/blog\/?p=3854"},"modified":"2020-07-12T16:56:09","modified_gmt":"2020-07-12T16:56:09","slug":"jasmine-errors-and-warnings","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/jasmine-errors-and-warnings\/","title":{"rendered":"Jasmine Errors and Warnings"},"content":{"rendered":"<p><strong>Angular 6 &#8211; NullInjectorError: No provider for HttpClient in unit tests<\/strong><br \/>\nIf you don&#8217;t import HttpClientModule (or HttpClientTestingModule) there, HttpClient won&#8217;t work because Angular doesn&#8217;t know about it. It doesn&#8217;t matter that you added HttpClientModule to, say, AppModule. It needs to be in TestBed.configureTestingModule.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nimport { TestBed } from '@angular\/core\/testing';\r\nimport { HttpClientTestingModule, HttpTestingController } from '@angular\/common\/http\/testing';\r\nimport {HttpClientModule} from '@angular\/common\/http';\r\n\r\ndescribe('myService', () =&gt; {\r\n.\r\n.\r\n.\r\n});\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Angular 6 &#8211; NullInjectorError: No provider for HttpClient in unit tests If you don&#8217;t import HttpClientModule (or HttpClientTestingModule) there, HttpClient won&#8217;t work because Angular doesn&#8217;t know about it. It doesn&#8217;t matter that you added HttpClientModule to, say, AppModule. It needs to be in TestBed.configureTestingModule. import { TestBed } from &#8216;@angular\/core\/testing&#8217;; import { HttpClientTestingModule, HttpTestingController }&hellip; <a href=\"https:\/\/codethataint.com\/blog\/jasmine-errors-and-warnings\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[318,319],"tags":[],"class_list":["post-3854","post","type-post","status-publish","format-standard","hentry","category-jasmine","category-errors-and-warnings-jasmine"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=3854"}],"version-history":[{"count":2,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3854\/revisions"}],"predecessor-version":[{"id":3856,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3854\/revisions\/3856"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=3854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=3854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=3854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}