Skip to content

Hybrid unit testing. #7

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

Merged
merged 6 commits into from
Jan 18, 2024
Merged

Hybrid unit testing. #7

merged 6 commits into from
Jan 18, 2024

Conversation

risal-shefin
Copy link
Owner

@risal-shefin risal-shefin commented Jan 16, 2024

Updates: #7 (comment) , #7 (comment)


Old Comment:

It will be merged after resolving the errors.

Use case: we are trying to test an angular directive that extends UpgradeComponent to upgrade an AngularJS component.

Issues:

Currently, it gives the following error when the "ng test" command is entered:
Error: Trying to get the AngularJS injector before it being set.

If TestBed.inject(UpgradeModule).bootstrap(document.documentElement, ['phonecatApp']); is used to bootstrap the angular js app in the test, it produces the following errors:
NullInjectorError: R3InjectorError(DynamicTestModule)[$scope -> $scope]
NullInjectorError: No provider for $scope!

Probable useful issue (still open): angular/angular#24369

Risal Shahriar Shefin added 5 commits January 16, 2024 13:37
Included build files also.
- Implemented mock angular phone service in phone list component's unit test.
- Updated karma config and angular.json.
- Other necessary changes.
@risal-shefin risal-shefin changed the title [NOT WORKING TILL NOW] Hybrid unit testing attempt Hybrid unit testing. Jan 17, 2024
@risal-shefin
Copy link
Owner Author

risal-shefin commented Jan 17, 2024

17 January update:

Now, both angular js and angular tests can be run using the "ng test" command. For this, we need to include the bundled angular js scripts file into the karma config.

  • For the angular js component using angular service, we need to mock the service in angular js tests.
  • Tests for directives extending UpgradeComponent are still not working.

@risal-shefin
Copy link
Owner Author

18 January Update:

Currently, using the directives that extend UpgradeComponent, we can test component creation.

@risal-shefin risal-shefin merged commit 251b480 into master Jan 18, 2024
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.

1 participant