fix(angular): use initialize function when setting up ionic angular to avoid config errors #24004
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build
) was run locally and any changes were pushednpm run lint
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
When angular bootstraps it sets
Ionic.config
regardless of whether it is set or not. This is fine in normal applications such as serving in the browser where angular is only initialised once.However in karma test suites angular is initialised on every test case but the window object persists between all test cases which causes ionic/angular to overwrite the config with something that is not compatible with the core components. This has been reported in #22853 as config.get throwing warnings when using ion-segment but I guess the issue could be for any components that use the config object.
Issue Number: 22853
What is the new behavior?
Now during startup ionic/angular checks to see if
Ionic.config
is set. If it is it does not do anything with that variable. This seems to solve the problem described in #22853 and I've not noticed any adverse effects when stepping through the event listeners in helpers that were previously failing because the config had been overwritten with another objectDoes this introduce a breaking change?
Other information
When inspecting Ionic.config on a second test case
PS: I wasn't able to find any tests for this part and running npm test gave me
angular no tests yet
. If theres some tests I need to write let me know and also how I should run the test suite.