BeastCode/VSCode-Angular-TypeScript-Snippets

Import statements for testing snippets

bradyhanna opened this issue · 1 comments

Should some of the testing snippets be including import statements?

An example is the t-service snippet

describe('NameService', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [NameService]
    });
  });
it('should be created', inject([NameService], (service: NameService) => {
  expect(service).toBeTruthy();
  }));
});

Suggested behavior:

import { TestBed, inject } from '@angular/core/testing';

describe('NameService', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [NameService]
    });
  });
it('should be created', inject([NameService], (service: NameService) => {
  expect(service).toBeTruthy();
  }));
});

could also optionally include the import for the service

import { TestBed, inject } from '@angular/core/testing';
import { NameService } from './name.service';

describe('NameService', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [NameService]
    });
  });
it('should be created', inject([NameService], (service: NameService) => {
  expect(service).toBeTruthy();
  }));
});

Thanks for your suggestion Brady!
I've added all your suggestions and published it in a new version.

Let me know what you think and if you have any other suggestion, please add them!

thanks /Mike