Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update NgModuleWithProviders interface #149

Closed

Conversation

vytautas-petrikas
Copy link

This should resolve the issue with Angular 10 #148.
However, I am not sure if versions prior to 9 will be compatible...

Either we need to remove the dependency on ModuleWithProviders from angular or to start documenting which ng-mocks versions should be used with which angular version.

Please let me know if anything needs to be adjusted.

@satanTime
Copy link
Member

Hi. Thanks for the PR. Please add a new interface MockNgModule... that fits all angular versions and we need to add angular 10 to e2e tests too.

@vytautas-petrikas
Copy link
Author

@satanTime To my understanding I just need to change

export interface NgModuleWithProviders<T = any> extends ModuleWithProviders {
  ngModule: Type<T>;
  providers?: Provider[];
}

to

export interface NgModuleWithProviders<T = any> {
  ngModule: Type<T>;
  providers?: Provider[];
}

And of course remove the unused import from @angular/core.

Please clarify if thats what you meant by Please add a new interface MockNgModule... that fits all angular version.

P.S. My windows decided to update will add base for e2e tests after update is finished.

@satanTime
Copy link
Member

Yep. Makes sense

@satanTime
Copy link
Member

For angular 10. please check in code :a9, the same things should be done for :a10.

@vytautas-petrikas
Copy link
Author

At the moment only angular10-ivy-true tests are failing, but I will be only able to debug further tomorrow in the evening.

@satanTime
Copy link
Member

Hi. Thanks for the info. I’m on vacation until Tuesday and won’t be available either.

No rush then. Next week we can solve it.

@vytautas-petrikas
Copy link
Author

All the tests succeed locally.
I Have implemented a testBedInjector constant which checks whether TestBed.inject or TestBed.get should be used.

const testBedInjector = TestBed['inject'] ? TestBed['inject'] : TestBed['get'];

Currently, I am using a string to check the availability of these methods as older versions did not have the inject method available.

I think it would be best to create a utility function or constant that can be imported into tests, but I am not sure where would be the best location to place it...

Any guidance on how to fix testBedInjector implementation to succeed on Travis would be appreciated.

@satanTime
Copy link
Member

first of all thanks for the effort, I checked it yesterday and due to braking changes in ts 3.9 (especially TS2339) to add support of angular 10 requires more changes than a removal of generic, I'll overtake this task.

expect(mock).toEqual(jasmine.any(CustomComponent));

// checking that it was processed through Mock
expect(mock.__ngMocksMock as any).toBe(true);
expect(mock.__ngMocksMockControlValueAccessor as any).toBe(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, it won't work like that and should be properly fixed to support TS 3.9. Due to required number of changes in architecture I have to overtake this task.

@vytautas-petrikas
Copy link
Author

@satanTime I just pushed one last change. I will no longer push new changes on this. Let me know if you need further assistance :)

@satanTime
Copy link
Member

@vytautas-petrikas, thanks again, might you squash all commits together? I'll try to use your branch as a base one for the full fix.

build: base for angular 10 e2e tests

fix: remove dependency on interface from angular

fix: change names in the index.html files

fix: do not inject APP_INITIALIZER token for version 10

fix: add helper constant testBedInjector

fix: compile Ivy dependencies for parallel test predictability

build: move testBedInjector into utils folder

fix: remove unused imports

fix: explicitly cast inject method as any for Angular 5

fix: cast TestBed to any instead of the key value

fix: cast mock to any
@vytautas-petrikas
Copy link
Author

I have squashed the commits

satanTime referenced this pull request in satanTime/ng-mocks Jul 1, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 1, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 1, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 1, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 2, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 2, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 2, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 2, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 2, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 2, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 2, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 4, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 4, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 4, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 4, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 4, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 4, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 4, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 4, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 4, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 4, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 5, 2020
BREAKING CHANGE: A10

closes #148, #149
satanTime referenced this pull request in satanTime/ng-mocks Jul 5, 2020
BREAKING CHANGE: A10

closes #148, #149
@satanTime
Copy link
Member

Hi again,

thanks for the effort, unfortunately, with all changes it required a lot of investigation and it was easier to provide a separate PR to fix all of them.

@satanTime satanTime closed this Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants