Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

feat: support using natural jasmine syntax when comp is not found#29

Open
Blackbaud-ColbyWhite wants to merge 1 commit intoblackbaud:masterfrom
Blackbaud-ColbyWhite:dne
Open

feat: support using natural jasmine syntax when comp is not found#29
Blackbaud-ColbyWhite wants to merge 1 commit intoblackbaud:masterfrom
Blackbaud-ColbyWhite:dne

Conversation

@Blackbaud-ColbyWhite
Copy link
Contributor

@Blackbaud-ColbyWhite Blackbaud-ColbyWhite commented Aug 8, 2019

Take the following case.

<sky-alert *ngIf=someBool></sky-alert>

if you want to write a test for the scenario when the sky-alert should not show up in the DOM, the previous strategy meant you had to write a test like such.

expect(() => SkyTestComponentSelector.selectAlert(fixture, 'myId')).toThrowError();

this doesn't read very well. the case you're trying to test doesn't relate to errors, yet the way you have to write your assertion involves knowing about an error getting thrown. a more preferred way to assert this would be the following:

expect(SkyTestComponentSelector.selectAlert(fixture, 'myId')).not.toExist();

this reads more explicitly as to what you're trying to assert in the test.

this PR restructures the component selector in order to allow for this type of assertion by returning undefined in the scenario where the component isn't found. this mimics how you would do assertions for regular DOM elements (i.e. expect(fixture.query('h1')).not.toExist())) in similar scenarios.

the downside is that the way i've written this, i'm pretty sure it would be a breaking change. so if there are any ideas as to how to move to the new behavior in a non-breaking fashion, i'm all ears. i was a bit stumped on that point.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant