Please provide us with the following information:
- OS? Ubuntu 16.04 LTS
- Versions. Please run
ng --version. If there's nothing outputted, please run
in a Terminal:node --versionand paste the result here:
angular-cli: 1.0.0-beta.15
node: 6.5.0
os: linux x64
I created a new Class using the ng g class generator. In this case, it was a class called user, so I got a user.ts and user.spec.ts
The generated user.spec.ts had the following content:
/* tslint:disable:no-unused-variable */
import { addProviders, async, inject } from '@angular/core/testing';
import {User} from './user';
describe('User', () => {
it('should create an instance', () => {
expect(new User()).toBeTruthy();
});
});
The addProviders give an error because it doesn't exist in @angular/core/testing
ERROR in [default] [...]/src/app/core/user/user.spec.ts:3:9
Module '"[...]/node_modules/@angular/core/testing/index"' has no exported member 'addProviders'.
Thanks! We'll be in touch soon.
AddProviders was deprecated. Use Testbed instead. Also this is angular specific not cli specific
@deebloo The thing is that the Angular CLI generates the test file with the AddProviders. I know they are deprecated, my issue was about stating the fact that Angular CLI shouldn't use AddProviders in the generated class.spec.ts
The newest version of the cli uses Testbed
That code looks like it is from an old version of the cli
My version of CLI is angular-cli: 1.0.0-beta.15.
The CLI is using TestBed in most generators (component, service...etc) But not in the class generator. You can check it if you want.
@Jeffarese nope you are totally correct. Looks like the class generator creates a bad test for class. (apologies I didn't see that you were generating class, thought it was service. Definitely a bug) Good catch
Yeah, I'm afraid it's a bug :( no apologies needed!
I just submitted a PR that removes those imports
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
I just submitted a PR that removes those imports