Skip to content

Import statements for testing snippets #94

@bradyhanna

Description

@bradyhanna

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();
  }));
});

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions