0

I am using Angular 4 with TestBed, as per the documents here: https://angular.io/guide/testing#service-tests

I have a simple Service:

@Injectable()
export class SimpleService {
  getValue() { return 'Hi'; }
}

And a test, which instantiates this Service using TestBed:

describe('SimpleService', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({ providers: [SimpleService] });
  });

  it('Should say Hello', () => {
    const testBedService: SimpleService = TestBed.get(SimpleService);
    const actual = testBedService.getValue();
    expect(actual).toBe('Hi');
  });
});

However, running this test with ng e2e gives me the following error:

Cannot assign to 'SimpleService' because it is not a variable

What do I need to change?

christofr
  • 2,680
  • 1
  • 18
  • 19

1 Answers1

1

This looks like a unit test, not an end-to-end test. If you run it with ng test it should work just fine.

codequiet
  • 1,102
  • 5
  • 9