title: TypeError: Failed to execute 'append' on 'FormData' parameter 2 is not type of 'Blob'
body: <p>I am new to writing test case for angular unit testing.
  Facing issue while writing the test case for below typescript.</p>
  <p><strong>editflag.component.ts</strong></p>
  <pre><code>private create(){
      const formData = this.constructFormData(this.flagClone,this.files.file,this.files.file,this.files.file.name);
      this.flagService.createFlag(formData).subscribe((response: any) =&gt; {
          if(response.label === 1 ){
              this.editFlagDialog.close(create);
          } else {
              this.message.showNotification('Failed to create.');
          }
      }, (error: HttpErrorResponse) =&gt; {
              console.log(error);
              this.message.showNotification('Failed to create.');
      });
  }
  
  private update(){
      const formData = this.constructFormData(this.flagClone,this.files.file,this.files.file,this.files.file.name);
      this.flagService.updateFlag(this.flagClone.id,formData).subscribe((response: any) =&gt; {
              this.editFlagDialog.close(edit);
          }
      }, (error: HttpErrorResponse) =&gt; {
              console.log(error);
              this.message.showNotification('Failed to update.');
      });
  }
  
  public constructFormData(meta, flagFile, thumbnail, filename): FormData {
      const formData = new FormData();
      
      formData.append('meta', this.addJson(meta));
      formData.append('logo', flagFile, filename);
      formData.append('thumbnail', thumbnail);
      return formData;
  }
  
  public addJson(jsonData): Blob {
      return new Blob ([JSON.stringfy(jsonData)], {type: 'application/json'});
  }
  </code></pre>
  <p>The test case which I have written are as follows:
  <strong>editFlag.spec.ts</strong></p>
  <pre><code>let mockFlagService;
  
  const testData: Client = {
          id: null, //string
          description: null,  //string
          url: null,      //string
          client: null
  };
  
  beforeEach(async(() =&gt; {
      TestBed.configureTestingModule({
        imports: [
          RouterTestingModule
        ],
        declarations: [
          EditFlagComponent
        ],
        providers: [
          HttpClient,
          HttpHandler,
          {provide: MatDialog, useValue: {} },
          {provide: MatDialogRef, useValue: {} },
          {provide: MAT_DIALOG_DATA, useValue: {testData} },
        ]
      }).compileComponents();
      mockFlagService = TestBed.inject(FlagService);
    }));
  
    beforeEach(() =&gt; {
      fixture = TestBed.createComponent(EditFlagComponent);
      component = fixture.componentInstance;
      fixture.detectChanges();
    });
    
  it('should call update',() =&gt; {
      const flagSpy = spyOn(mockFlagService, 'updateFlag').and.returnValue(of(testData));
      fixture.detectChanges();
      component.update()
      expect(flagSpy).toHaveBeenCalled();
  });
  </code></pre>
  <p>But I am getting this error <em>TypeError: Failed to execute 'append' on 'FormData' parameter 2 is not type of 'Blob'</em></p>