qunit-dom icon indicating copy to clipboard operation
qunit-dom copied to clipboard

Add `hasChild` method to assert that child element exists

Open jelhan opened this issue 2 years ago • 0 comments

A hasChild method would be helpful to assert that a child element exists.

Currently I find myself writing something like this from time to time:

assert
  .dom('foo')
  .hasText('...', 'renders text');
assert
  .dom('foo .bar')
  .exists('renders expected child element');

For readability it would be great if I could do this instead:

assert
  .dom('foo')
  .hasText('...', 'renders text')
  .hasChild('.bar', 'renders expected child element');

This may be addressed by #1579 as well. But I think hasChild would be more handy for simple cases, in which you only want to assert that a child element exists.

jelhan avatar May 23 '22 06:05 jelhan