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: fix query regression and unit testing improvements #148

Merged
merged 1 commit into from
Aug 8, 2019

Conversation

dirkluijk
Copy link
Collaborator

@dirkluijk dirkluijk commented Aug 7, 2019

OK, so I was a bit stubborn and decided to try to fix the regression.

In this PR:

  • The regression was caused by the SpectatorDebugElementNotFoundError error which was thrown and catched immediately - but not in all cases. I removed the throw-and-catch mechanism in favour of a silent return of null (which is expected in all cases, especially for matchers like toExist().
  • In order to see the coverage of projects/spectator instead of src, I needed to move the "test" builder to the spectator library project. I did not move any test files around and decided to postpone a complete new test setup for a later moment (soon). For the current coverage, see the screenshot below.
  • Added some @deprecated annotations for untested files.

image

I think this fixes the issues in #147 as well. I'll take a look.

Closes #146 (added additional test case).

I don't see any issues anymore?

"test:jest": "npx ng run spectator-app:test-jest",
"test:jest:watch": "npx ng run spectator-app:test-jest --watch",
Copy link
Member

Choose a reason for hiding this comment

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

Why you removed the watch option?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You can run both test and test:jest in watch mode with --watch so it felt a bit unneeded. ;-)

}

return child;
return _getChildren<R>(debugElementRoot)(directiveOrSelector, options)[0] || null;
Copy link
Member

Choose a reason for hiding this comment

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

I think we should at least add console info so that users will know what is missing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But that was before also not the case, right? Because the error was catched?

Copy link
Member

Choose a reason for hiding this comment

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

There was throw error

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, sorry, I see. I'll fix it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, well, it is still thrown right? Because it is not catched?

@@ -5,6 +5,7 @@ import { Directive, EventEmitter, Type } from '@angular/core';
* MockDirective({ selector: 'some-directive' });
* MockDirective({ selector: 'some-directive', inputs: ['some-input', 'some-other-input'] });
*
* @deprecated Deprecated in favour of the `ng-mocks` implementation of `MockDirective`. To be be removed in the next major version.
Copy link
Member

Choose a reason for hiding this comment

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

Removed in v4 PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🚀

@NetanelBasal
Copy link
Member

@dirkluijk, please merge it to master and release a new version that fixes the regression.

@dirkluijk dirkluijk merged commit 3503bee into master Aug 8, 2019
@dirkluijk dirkluijk deleted the fix/improve-unit-tests-regression-fixes branch August 8, 2019 13:38
@dirkluijk
Copy link
Collaborator Author

Of course.

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.

Can't find a debug element for <selector>
2 participants