1 |
|
2 |
|
3 | ### Table of Contents
|
4 |
|
5 | - [assert.dom()][1]
|
6 | - [DOMAssertions][2]
|
7 | - [exists][3]
|
8 | - [Parameters][4]
|
9 | - [Examples][5]
|
10 | - [doesNotExist][6]
|
11 | - [Parameters][7]
|
12 | - [Examples][8]
|
13 | - [isChecked][9]
|
14 | - [Parameters][10]
|
15 | - [Examples][11]
|
16 | - [isNotChecked][12]
|
17 | - [Parameters][13]
|
18 | - [Examples][14]
|
19 | - [isFocused][15]
|
20 | - [Parameters][16]
|
21 | - [Examples][17]
|
22 | - [isNotFocused][18]
|
23 | - [Parameters][19]
|
24 | - [Examples][20]
|
25 | - [isRequired][21]
|
26 | - [Parameters][22]
|
27 | - [Examples][23]
|
28 | - [isNotRequired][24]
|
29 | - [Parameters][25]
|
30 | - [Examples][26]
|
31 | - [isValid][27]
|
32 | - [Parameters][28]
|
33 | - [Examples][29]
|
34 | - [isNotValid][30]
|
35 | - [Parameters][31]
|
36 | - [Examples][32]
|
37 | - [isVisible][33]
|
38 | - [Parameters][34]
|
39 | - [Examples][35]
|
40 | - [isNotVisible][36]
|
41 | - [Parameters][37]
|
42 | - [Examples][38]
|
43 | - [hasAttribute][39]
|
44 | - [Parameters][40]
|
45 | - [Examples][41]
|
46 | - [doesNotHaveAttribute][42]
|
47 | - [Parameters][43]
|
48 | - [Examples][44]
|
49 | - [hasAria][45]
|
50 | - [Parameters][46]
|
51 | - [Examples][47]
|
52 | - [doesNotHaveAria][48]
|
53 | - [Parameters][49]
|
54 | - [Examples][50]
|
55 | - [hasProperty][51]
|
56 | - [Parameters][52]
|
57 | - [Examples][53]
|
58 | - [isDisabled][54]
|
59 | - [Parameters][55]
|
60 | - [Examples][56]
|
61 | - [isNotDisabled][57]
|
62 | - [Parameters][58]
|
63 | - [Examples][59]
|
64 | - [hasClass][60]
|
65 | - [Parameters][61]
|
66 | - [Examples][62]
|
67 | - [doesNotHaveClass][63]
|
68 | - [Parameters][64]
|
69 | - [Examples][65]
|
70 | - [hasStyle][66]
|
71 | - [Parameters][67]
|
72 | - [Examples][68]
|
73 | - [hasPseudoElementStyle][69]
|
74 | - [Parameters][70]
|
75 | - [Examples][71]
|
76 | - [doesNotHaveStyle][72]
|
77 | - [Parameters][73]
|
78 | - [Examples][74]
|
79 | - [doesNotHavePseudoElementStyle][75]
|
80 | - [Parameters][76]
|
81 | - [Examples][77]
|
82 | - [hasText][78]
|
83 | - [Parameters][79]
|
84 | - [Examples][80]
|
85 | - [hasAnyText][81]
|
86 | - [Parameters][82]
|
87 | - [Examples][83]
|
88 | - [hasNoText][84]
|
89 | - [Parameters][85]
|
90 | - [Examples][86]
|
91 | - [includesText][87]
|
92 | - [Parameters][88]
|
93 | - [Examples][89]
|
94 | - [doesNotIncludeText][90]
|
95 | - [Parameters][91]
|
96 | - [Examples][92]
|
97 | - [hasValue][93]
|
98 | - [Parameters][94]
|
99 | - [Examples][95]
|
100 | - [hasAnyValue][96]
|
101 | - [Parameters][97]
|
102 | - [Examples][98]
|
103 | - [hasNoValue][99]
|
104 | - [Parameters][100]
|
105 | - [Examples][101]
|
106 | - [matchesSelector][102]
|
107 | - [Parameters][103]
|
108 | - [Examples][104]
|
109 | - [doesNotMatchSelector][105]
|
110 | - [Parameters][106]
|
111 | - [Examples][107]
|
112 | - [hasTagName][108]
|
113 | - [Parameters][109]
|
114 | - [Examples][110]
|
115 | - [doesNotHaveTagName][111]
|
116 | - [Parameters][112]
|
117 | - [Examples][113]
|
118 |
|
119 | ## assert.dom()
|
120 |
|
121 | Once installed the DOM element assertions are available at `assert.dom(...).*`:
|
122 |
|
123 | **Parameters**
|
124 |
|
125 | - `target` **([string][114] \| [HTMLElement][115])** A CSS selector that can be used to find elements using [`querySelector()`][116], or an [HTMLElement][] (Not all assertions support both target types.) (optional, default `rootElement` or `document`)
|
126 | - `rootElement` **[HTMLElement][115]?** The root element of the DOM in which to search for the `target` (optional, default `document`)
|
127 |
|
128 | **Examples**
|
129 |
|
130 | ```javascript
|
131 | test('the title exists', function(assert) {
|
132 | assert.dom('#title').exists();
|
133 | });
|
134 | ```
|
135 |
|
136 |
|
137 | ## DOMAssertions
|
138 |
|
139 | ### exists
|
140 |
|
141 | - **See: [#doesNotExist][117]
|
142 | **
|
143 |
|
144 | Assert an [HTMLElement][118] (or multiple) matching the `selector` exists.
|
145 |
|
146 | #### Parameters
|
147 |
|
148 | - `options` **[object][119]?**
|
149 | - `options.count` **[number][120]?**
|
150 | - `message` **[string][121]?**
|
151 |
|
152 | #### Examples
|
153 |
|
154 | ```javascript
|
155 | assert.dom('#title').exists();
|
156 | assert.dom('.choice').exists({ count: 4 });
|
157 | ```
|
158 |
|
159 | ### doesNotExist
|
160 |
|
161 | - **See: [#exists][3]
|
162 | **
|
163 |
|
164 | Assert an [HTMLElement][118] matching the `selector` does not exists.
|
165 |
|
166 | #### Parameters
|
167 |
|
168 | - `message` **[string][121]?**
|
169 |
|
170 | #### Examples
|
171 |
|
172 | ```javascript
|
173 | assert.dom('.should-not-exist').doesNotExist();
|
174 | ```
|
175 |
|
176 | ### isChecked
|
177 |
|
178 | - **See: [#isNotChecked][122]
|
179 | **
|
180 |
|
181 | Assert that the [HTMLElement][118] or an [HTMLElement][118] matching the
|
182 | `selector` is currently checked.
|
183 |
|
184 | Note: This also supports `aria-checked="true/false"`.
|
185 |
|
186 | #### Parameters
|
187 |
|
188 | - `message` **[string][121]?**
|
189 |
|
190 | #### Examples
|
191 |
|
192 | ```javascript
|
193 | assert.dom('input.active').isChecked();
|
194 | ```
|
195 |
|
196 | ### isNotChecked
|
197 |
|
198 | - **See: [#isChecked][123]
|
199 | **
|
200 |
|
201 | Assert that the [HTMLElement][118] or an [HTMLElement][118] matching the
|
202 | `selector` is currently unchecked.
|
203 |
|
204 | Note: This also supports `aria-checked="true/false"`.
|
205 |
|
206 | #### Parameters
|
207 |
|
208 | - `message` **[string][121]?**
|
209 |
|
210 | #### Examples
|
211 |
|
212 | ```javascript
|
213 | assert.dom('input.active').isNotChecked();
|
214 | ```
|
215 |
|
216 | ### isFocused
|
217 |
|
218 | - **See: [#isNotFocused][124]
|
219 | **
|
220 |
|
221 | Assert that the [HTMLElement][118] or an [HTMLElement][118] matching the
|
222 | `selector` is currently focused.
|
223 |
|
224 | #### Parameters
|
225 |
|
226 | - `message` **[string][121]?**
|
227 |
|
228 | #### Examples
|
229 |
|
230 | ```javascript
|
231 | assert.dom('input.email').isFocused();
|
232 | ```
|
233 |
|
234 | ### isNotFocused
|
235 |
|
236 | - **See: [#isFocused][125]
|
237 | **
|
238 |
|
239 | Assert that the [HTMLElement][118] or an [HTMLElement][118] matching the
|
240 | `selector` is not currently focused.
|
241 |
|
242 | #### Parameters
|
243 |
|
244 | - `message` **[string][121]?**
|
245 |
|
246 | #### Examples
|
247 |
|
248 | ```javascript
|
249 | assert.dom('input[type="password"]').isNotFocused();
|
250 | ```
|
251 |
|
252 | ### isRequired
|
253 |
|
254 | - **See: [#isNotRequired][126]
|
255 | **
|
256 |
|
257 | Assert that the [HTMLElement][118] or an [HTMLElement][118] matching the
|
258 | `selector` is currently required.
|
259 |
|
260 | #### Parameters
|
261 |
|
262 | - `message` **[string][121]?**
|
263 |
|
264 | #### Examples
|
265 |
|
266 | ```javascript
|
267 | assert.dom('input[type="text"]').isRequired();
|
268 | ```
|
269 |
|
270 | ### isNotRequired
|
271 |
|
272 | - **See: [#isRequired][127]
|
273 | **
|
274 |
|
275 | Assert that the [HTMLElement][118] or an [HTMLElement][118] matching the
|
276 | `selector` is currently not required.
|
277 |
|
278 | #### Parameters
|
279 |
|
280 | - `message` **[string][121]?**
|
281 |
|
282 | #### Examples
|
283 |
|
284 | ```javascript
|
285 | assert.dom('input[type="text"]').isNotRequired();
|
286 | ```
|
287 |
|
288 | ### isValid
|
289 |
|
290 | - **See: [#isValid][128]
|
291 | **
|
292 |
|
293 | Assert that the [HTMLElement][118] passes validation
|
294 |
|
295 | Validity is determined by asserting that:
|
296 |
|
297 | - `element.reportValidity() === true`
|
298 |
|
299 | #### Parameters
|
300 |
|
301 | - `message` **[string][121]?**
|
302 |
|
303 | #### Examples
|
304 |
|
305 | ```javascript
|
306 | assert.dom('.input').isValid();
|
307 | ```
|
308 |
|
309 | ### isNotValid
|
310 |
|
311 | - **See: [#isValid][128]
|
312 | **
|
313 |
|
314 | Assert that the [HTMLElement][118] does not pass validation
|
315 |
|
316 | Validity is determined by asserting that:
|
317 |
|
318 | - `element.reportValidity() === true`
|
319 |
|
320 | #### Parameters
|
321 |
|
322 | - `message` **[string][121]?**
|
323 |
|
324 | #### Examples
|
325 |
|
326 | ```javascript
|
327 | assert.dom('.input').isNotValid();
|
328 | ```
|
329 |
|
330 | ### isVisible
|
331 |
|
332 | - **See: [#isNotVisible][129]
|
333 | **
|
334 |
|
335 | Assert that the [HTMLElement][118] or an [HTMLElement][118] matching the
|
336 | `selector` exists and is visible.
|
337 |
|
338 | Visibility is determined by asserting that:
|
339 |
|
340 | - the element's offsetWidth and offsetHeight are non-zero
|
341 | - any of the element's DOMRect objects have a non-zero size
|
342 |
|
343 | Additionally, visibility in this case means that the element is visible on the page,
|
344 | but not necessarily in the viewport.
|
345 |
|
346 | #### Parameters
|
347 |
|
348 | - `options` **[object][119]?**
|
349 | - `options.count` **[number][120]?**
|
350 | - `message` **[string][121]?**
|
351 |
|
352 | #### Examples
|
353 |
|
354 | ```javascript
|
355 | assert.dom('#title').isVisible();
|
356 | assert.dom('.choice').isVisible({ count: 4 });
|
357 | ```
|
358 |
|
359 | ### isNotVisible
|
360 |
|
361 | - **See: [#isVisible][130]
|
362 | **
|
363 |
|
364 | Assert that the [HTMLElement][118] or an [HTMLElement][118] matching the
|
365 | `selector` does not exist or is not visible on the page.
|
366 |
|
367 | Visibility is determined by asserting that:
|
368 |
|
369 | - the element's offsetWidth or offsetHeight are zero
|
370 | - all of the element's DOMRect objects have a size of zero
|
371 |
|
372 | Additionally, visibility in this case means that the element is visible on the page,
|
373 | but not necessarily in the viewport.
|
374 |
|
375 | #### Parameters
|
376 |
|
377 | - `message` **[string][121]?**
|
378 |
|
379 | #### Examples
|
380 |
|
381 | ```javascript
|
382 | assert.dom('.foo').isNotVisible();
|
383 | ```
|
384 |
|
385 | ### hasAttribute
|
386 |
|
387 | - **See: [#doesNotHaveAttribute][131]
|
388 | **
|
389 |
|
390 | Assert that the [HTMLElement][118] has an attribute with the provided `name`
|
391 | and optionally checks if the attribute `value` matches the provided text
|
392 | or regular expression.
|
393 |
|
394 | #### Parameters
|
395 |
|
396 | - `name` **[string][121]**
|
397 | - `value` **([string][121] \| [RegExp][132] \| [object][119]?)**
|
398 | - `message` **[string][121]?**
|
399 |
|
400 | #### Examples
|
401 |
|
402 | ```javascript
|
403 | assert.dom('input.password-input').hasAttribute('type', 'password');
|
404 | ```
|
405 |
|
406 | ### doesNotHaveAttribute
|
407 |
|
408 | - **See: [#hasAttribute][133]
|
409 | **
|
410 |
|
411 | Assert that the [HTMLElement][118] has no attribute with the provided `name`.
|
412 |
|
413 | **Aliases:** `hasNoAttribute`, `lacksAttribute`
|
414 |
|
415 | #### Parameters
|
416 |
|
417 | - `name` **[string][121]**
|
418 | - `message` **[string][121]?**
|
419 |
|
420 | #### Examples
|
421 |
|
422 | ```javascript
|
423 | assert.dom('input.username').hasNoAttribute('disabled');
|
424 | ```
|
425 |
|
426 | ### hasAria
|
427 |
|
428 | - **See: [#hasNoAria][134]
|
429 | **
|
430 |
|
431 | Assert that the [HTMLElement][118] has an ARIA attribute with the provided
|
432 | `name` and optionally checks if the attribute `value` matches the provided
|
433 | text or regular expression.
|
434 |
|
435 | #### Parameters
|
436 |
|
437 | - `name` **[string][121]**
|
438 | - `value` **([string][121] \| [RegExp][132] \| [object][119]?)**
|
439 | - `message` **[string][121]?**
|
440 |
|
441 | #### Examples
|
442 |
|
443 | ```javascript
|
444 | assert.dom('button').hasAria('pressed', 'true');
|
445 | ```
|
446 |
|
447 | ### doesNotHaveAria
|
448 |
|
449 | - **See: [#hasAria][135]
|
450 | **
|
451 |
|
452 | Assert that the [HTMLElement][118] has no ARIA attribute with the
|
453 | provided `name`.
|
454 |
|
455 | #### Parameters
|
456 |
|
457 | - `name` **[string][121]**
|
458 | - `message` **[string][121]?**
|
459 |
|
460 | #### Examples
|
461 |
|
462 | ```javascript
|
463 | assert.dom('button').doesNotHaveAria('pressed');
|
464 | ```
|
465 |
|
466 | ### hasProperty
|
467 |
|
468 | - **See: [#doesNotHaveProperty][136]
|
469 | **
|
470 |
|
471 | Assert that the [HTMLElement][118] has a property with the provided `name`
|
472 | and checks if the property `value` matches the provided text or regular
|
473 | expression.
|
474 |
|
475 | #### Parameters
|
476 |
|
477 | - `name` **[string][121]**
|
478 | - `value` **([RegExp][132] | any)**
|
479 | - `message` **[string][121]?**
|
480 |
|
481 | #### Examples
|
482 |
|
483 | ```javascript
|
484 | assert.dom('input.password-input').hasProperty('type', 'password');
|
485 | ```
|
486 |
|
487 | ### isDisabled
|
488 |
|
489 | - **See: [#isNotDisabled][137]
|
490 | **
|
491 |
|
492 | Assert that the [HTMLElement][118] or an [HTMLElement][118] matching the
|
493 | `selector` is disabled.
|
494 |
|
495 | #### Parameters
|
496 |
|
497 | - `message` **[string][121]?**
|
498 |
|
499 | #### Examples
|
500 |
|
501 | ```javascript
|
502 | assert.dom('.foo').isDisabled();
|
503 | ```
|
504 |
|
505 | ### isNotDisabled
|
506 |
|
507 | - **See: [#isDisabled][138]
|
508 | **
|
509 |
|
510 | Assert that the [HTMLElement][118] or an [HTMLElement][118] matching the
|
511 | `selector` is not disabled.
|
512 |
|
513 | **Aliases:** `isEnabled`
|
514 |
|
515 | #### Parameters
|
516 |
|
517 | - `message` **[string][121]?**
|
518 |
|
519 | #### Examples
|
520 |
|
521 | ```javascript
|
522 | assert.dom('.foo').isNotDisabled();
|
523 | ```
|
524 |
|
525 | ### hasClass
|
526 |
|
527 | - **See: [#doesNotHaveClass][139]
|
528 | **
|
529 |
|
530 | Assert that the [HTMLElement][118] has the `expected` CSS class using
|
531 | [`classList`][140].
|
532 |
|
533 | `expected` can also be a regular expression, and the assertion will return
|
534 | true if any of the element's CSS classes match.
|
535 |
|
536 | #### Parameters
|
537 |
|
538 | - `expected` **([string][121] \| [RegExp][132])**
|
539 | - `message` **[string][121]?**
|
540 |
|
541 | #### Examples
|
542 |
|
543 | ```javascript
|
544 | assert.dom('input[type="password"]').hasClass('secret-password-input');
|
545 | ```
|
546 |
|
547 | ```javascript
|
548 | assert.dom('input[type="password"]').hasClass(/.*password-input/);
|
549 | ```
|
550 |
|
551 | ### doesNotHaveClass
|
552 |
|
553 | - **See: [#hasClass][141]
|
554 | **
|
555 |
|
556 | Assert that the [HTMLElement][118] does not have the `expected` CSS class using
|
557 | [`classList`][140].
|
558 |
|
559 | `expected` can also be a regular expression, and the assertion will return
|
560 | true if none of the element's CSS classes match.
|
561 |
|
562 | **Aliases:** `hasNoClass`, `lacksClass`
|
563 |
|
564 | #### Parameters
|
565 |
|
566 | - `expected` **([string][121] \| [RegExp][132])**
|
567 | - `message` **[string][121]?**
|
568 |
|
569 | #### Examples
|
570 |
|
571 | ```javascript
|
572 | assert.dom('input[type="password"]').doesNotHaveClass('username-input');
|
573 | ```
|
574 |
|
575 | ```javascript
|
576 | assert.dom('input[type="password"]').doesNotHaveClass(/username-.*-input/);
|
577 | ```
|
578 |
|
579 | ### hasStyle
|
580 |
|
581 | - **See: [#hasClass][141]
|
582 | **
|
583 |
|
584 | Assert that the [HTMLElement][] has the `expected` style declarations using
|
585 | [`window.getComputedStyle`][142].
|
586 |
|
587 | #### Parameters
|
588 |
|
589 | - `expected` **[object][119]**
|
590 | - `message` **[string][121]?**
|
591 |
|
592 | #### Examples
|
593 |
|
594 | ```javascript
|
595 | assert.dom('.progress-bar').hasStyle({
|
596 | opacity: 1,
|
597 | display: 'block'
|
598 | });
|
599 | ```
|
600 |
|
601 | ### hasPseudoElementStyle
|
602 |
|
603 | - **See: [#hasClass][141]
|
604 | **
|
605 |
|
606 | Assert that the pseudo element for `selector` of the [HTMLElement][] has the `expected` style declarations using
|
607 | [`window.getComputedStyle`][142].
|
608 |
|
609 | #### Parameters
|
610 |
|
611 | - `selector` **[string][121]**
|
612 | - `expected` **[object][119]**
|
613 | - `message` **[string][121]?**
|
614 |
|
615 | #### Examples
|
616 |
|
617 | ```javascript
|
618 | assert.dom('.progress-bar').hasPseudoElementStyle(':after', {
|
619 | content: '";"',
|
620 | });
|
621 | ```
|
622 |
|
623 | ### doesNotHaveStyle
|
624 |
|
625 | - **See: [#hasClass][141]
|
626 | **
|
627 |
|
628 | Assert that the [HTMLElement][] does not have the `expected` style declarations using
|
629 | [`window.getComputedStyle`][142].
|
630 |
|
631 | #### Parameters
|
632 |
|
633 | - `expected` **[object][119]**
|
634 | - `message` **[string][121]?**
|
635 |
|
636 | #### Examples
|
637 |
|
638 | ```javascript
|
639 | assert.dom('.progress-bar').doesNotHaveStyle({
|
640 | opacity: 1,
|
641 | display: 'block'
|
642 | });
|
643 | ```
|
644 |
|
645 | ### doesNotHavePseudoElementStyle
|
646 |
|
647 | - **See: [#hasClass][141]
|
648 | **
|
649 |
|
650 | Assert that the pseudo element for `selector` of the [HTMLElement][] does not have the `expected` style declarations using
|
651 | [`window.getComputedStyle`][142].
|
652 |
|
653 | #### Parameters
|
654 |
|
655 | - `selector` **[string][121]**
|
656 | - `expected` **[object][119]**
|
657 | - `message` **[string][121]?**
|
658 |
|
659 | #### Examples
|
660 |
|
661 | ```javascript
|
662 | assert.dom('.progress-bar').doesNotHavePseudoElementStyle(':after', {
|
663 | content: '";"',
|
664 | });
|
665 | ```
|
666 |
|
667 | ### hasText
|
668 |
|
669 | - **See: [#includesText][143]
|
670 | **
|
671 |
|
672 | Assert that the text of the [HTMLElement][118] or an [HTMLElement][118]
|
673 | matching the `selector` matches the `expected` text, using the
|
674 | [`textContent`][144]
|
675 | attribute and stripping/collapsing whitespace.
|
676 |
|
677 | `expected` can also be a regular expression.
|
678 |
|
679 | > Note: This assertion will collapse whitespace if the type you pass in is a string.
|
680 | > If you are testing specifically for whitespace integrity, pass your expected text
|
681 | > in as a RegEx pattern.
|
682 |
|
683 | **Aliases:** `matchesText`
|
684 |
|
685 | #### Parameters
|
686 |
|
687 | - `expected` **([string][121] \| [RegExp][132])**
|
688 | - `message` **[string][121]?**
|
689 |
|
690 | #### Examples
|
691 |
|
692 | ```javascript
|
693 | // <h2 id="title">
|
694 | // Welcome to <b>QUnit</b>
|
695 | // </h2>
|
696 |
|
697 | assert.dom('#title').hasText('Welcome to QUnit');
|
698 | ```
|
699 |
|
700 | ```javascript
|
701 | assert.dom('.foo').hasText(/[12]\d{3}/);
|
702 | ```
|
703 |
|
704 | ### hasAnyText
|
705 |
|
706 | - **See: [#hasText][145]
|
707 | **
|
708 |
|
709 | Assert that the `textContent` property of an [HTMLElement][118] is not empty.
|
710 |
|
711 | #### Parameters
|
712 |
|
713 | - `message` **[string][121]?**
|
714 |
|
715 | #### Examples
|
716 |
|
717 | ```javascript
|
718 | assert.dom('button.share').hasAnyText();
|
719 | ```
|
720 |
|
721 | ### hasNoText
|
722 |
|
723 | - **See: [#hasNoText][146]
|
724 | **
|
725 |
|
726 | Assert that the `textContent` property of an [HTMLElement][118] is empty.
|
727 |
|
728 | #### Parameters
|
729 |
|
730 | - `message` **[string][121]?**
|
731 |
|
732 | #### Examples
|
733 |
|
734 | ```javascript
|
735 | assert.dom('div').hasNoText();
|
736 | ```
|
737 |
|
738 | ### includesText
|
739 |
|
740 | - **See: [#hasText][145]
|
741 | **
|
742 |
|
743 | Assert that the text of the [HTMLElement][118] or an [HTMLElement][118]
|
744 | matching the `selector` contains the given `text`, using the
|
745 | [`textContent`][144]
|
746 | attribute.
|
747 |
|
748 | > Note: This assertion will collapse whitespace in `textContent` before searching.
|
749 | > If you would like to assert on a string that _should_ contain line breaks, tabs,
|
750 | > more than one space in a row, or starting/ending whitespace, use the [#hasText][145]
|
751 | > selector and pass your expected text in as a RegEx pattern.
|
752 |
|
753 | **Aliases:** `containsText`, `hasTextContaining`
|
754 |
|
755 | #### Parameters
|
756 |
|
757 | - `text` **[string][121]**
|
758 | - `message` **[string][121]?**
|
759 |
|
760 | #### Examples
|
761 |
|
762 | ```javascript
|
763 | assert.dom('#title').includesText('Welcome');
|
764 | ```
|
765 |
|
766 | ### doesNotIncludeText
|
767 |
|
768 | Assert that the text of the [HTMLElement][118] or an [HTMLElement][118]
|
769 | matching the `selector` does not include the given `text`, using the
|
770 | [`textContent`][144]
|
771 | attribute.
|
772 |
|
773 | **Aliases:** `doesNotContainText`, `doesNotHaveTextContaining`
|
774 |
|
775 | #### Parameters
|
776 |
|
777 | - `text` **[string][121]**
|
778 | - `message` **[string][121]?**
|
779 |
|
780 | #### Examples
|
781 |
|
782 | ```javascript
|
783 | assert.dom('#title').doesNotIncludeText('Welcome');
|
784 | ```
|
785 |
|
786 | ### hasValue
|
787 |
|
788 | - **See: [#hasAnyValue][147]
|
789 | **
|
790 | - **See: [#hasNoValue][148]
|
791 | **
|
792 |
|
793 | Assert that the `value` property of an [HTMLInputElement][149] matches
|
794 | the `expected` text or regular expression.
|
795 |
|
796 | If no `expected` value is provided, the assertion will fail if the
|
797 | `value` is an empty string.
|
798 |
|
799 | #### Parameters
|
800 |
|
801 | - `expected` **([string][121] \| [RegExp][132] \| [object][119]?)**
|
802 | - `message` **[string][121]?**
|
803 |
|
804 | #### Examples
|
805 |
|
806 | ```javascript
|
807 | assert.dom('input.username').hasValue('HSimpson');
|
808 | ```
|
809 |
|
810 | ### hasAnyValue
|
811 |
|
812 | - **See: [#hasValue][150]
|
813 | **
|
814 | - **See: [#hasNoValue][148]
|
815 | **
|
816 |
|
817 | Assert that the `value` property of an [HTMLInputElement][149] is not empty.
|
818 |
|
819 | #### Parameters
|
820 |
|
821 | - `message` **[string][121]?**
|
822 |
|
823 | #### Examples
|
824 |
|
825 | ```javascript
|
826 | assert.dom('input.username').hasAnyValue();
|
827 | ```
|
828 |
|
829 | ### hasNoValue
|
830 |
|
831 | - **See: [#hasValue][150]
|
832 | **
|
833 | - **See: [#hasAnyValue][147]
|
834 | **
|
835 |
|
836 | Assert that the `value` property of an [HTMLInputElement][149] is empty.
|
837 |
|
838 | **Aliases:** `lacksValue`
|
839 |
|
840 | #### Parameters
|
841 |
|
842 | - `message` **[string][121]?**
|
843 |
|
844 | #### Examples
|
845 |
|
846 | ```javascript
|
847 | assert.dom('input.username').hasNoValue();
|
848 | ```
|
849 |
|
850 | ### matchesSelector
|
851 |
|
852 | Assert that the target selector selects only Elements that are also selected by
|
853 | compareSelector.
|
854 |
|
855 | #### Parameters
|
856 |
|
857 | - `compareSelector` **[string][121]**
|
858 | - `message` **[string][121]?**
|
859 |
|
860 | #### Examples
|
861 |
|
862 | ```javascript
|
863 | assert.dom('p.red').matchesSelector('div.wrapper p:last-child')
|
864 | ```
|
865 |
|
866 | ### doesNotMatchSelector
|
867 |
|
868 | Assert that the target selector selects only Elements that are not also selected by
|
869 | compareSelector.
|
870 |
|
871 | #### Parameters
|
872 |
|
873 | - `compareSelector` **[string][121]**
|
874 | - `message` **[string][121]?**
|
875 |
|
876 | #### Examples
|
877 |
|
878 | ```javascript
|
879 | assert.dom('input').doesNotMatchSelector('input[disabled]')
|
880 | ```
|
881 |
|
882 | ### hasTagName
|
883 |
|
884 | Assert that the tagName of the [HTMLElement][118] or an [HTMLElement][118]
|
885 | matching the `selector` matches the `expected` tagName, using the
|
886 | [`tagName`][151]
|
887 | property of the [HTMLElement][118].
|
888 |
|
889 | #### Parameters
|
890 |
|
891 | - `tagName`
|
892 | - `message` **[string][121]?**
|
893 | - `expected` **[string][121]**
|
894 |
|
895 | #### Examples
|
896 |
|
897 | ```javascript
|
898 | // <h1 id="title">
|
899 | // Title
|
900 | // </h1>
|
901 |
|
902 | assert.dom('#title').hasTagName('h1');
|
903 | ```
|
904 |
|
905 | ### doesNotHaveTagName
|
906 |
|
907 | Assert that the tagName of the [HTMLElement][118] or an [HTMLElement][118]
|
908 | matching the `selector` does not match the `expected` tagName, using the
|
909 | [`tagName`][151]
|
910 | property of the [HTMLElement][118].
|
911 |
|
912 | #### Parameters
|
913 |
|
914 | - `tagName`
|
915 | - `message` **[string][121]?**
|
916 | - `expected` **[string][121]**
|
917 |
|
918 | #### Examples
|
919 |
|
920 | ```javascript
|
921 | // <section id="block">
|
922 | // Title
|
923 | // </section>
|
924 |
|
925 | assert.dom('section#block').doesNotHaveTagName('div');
|
926 | ```
|
927 |
|
928 | [1]: #assertdom
|
929 |
|
930 | [2]: #domassertions
|
931 |
|
932 | [3]: #exists
|
933 |
|
934 | [4]: #parameters
|
935 |
|
936 | [5]: #examples
|
937 |
|
938 | [6]: #doesnotexist
|
939 |
|
940 | [7]: #parameters-1
|
941 |
|
942 | [8]: #examples-1
|
943 |
|
944 | [9]: #ischecked
|
945 |
|
946 | [10]: #parameters-2
|
947 |
|
948 | [11]: #examples-2
|
949 |
|
950 | [12]: #isnotchecked
|
951 |
|
952 | [13]: #parameters-3
|
953 |
|
954 | [14]: #examples-3
|
955 |
|
956 | [15]: #isfocused
|
957 |
|
958 | [16]: #parameters-4
|
959 |
|
960 | [17]: #examples-4
|
961 |
|
962 | [18]: #isnotfocused
|
963 |
|
964 | [19]: #parameters-5
|
965 |
|
966 | [20]: #examples-5
|
967 |
|
968 | [21]: #isrequired
|
969 |
|
970 | [22]: #parameters-6
|
971 |
|
972 | [23]: #examples-6
|
973 |
|
974 | [24]: #isnotrequired
|
975 |
|
976 | [25]: #parameters-7
|
977 |
|
978 | [26]: #examples-7
|
979 |
|
980 | [27]: #isvalid
|
981 |
|
982 | [28]: #parameters-8
|
983 |
|
984 | [29]: #examples-8
|
985 |
|
986 | [30]: #isnotvalid
|
987 |
|
988 | [31]: #parameters-9
|
989 |
|
990 | [32]: #examples-9
|
991 |
|
992 | [33]: #isvisible
|
993 |
|
994 | [34]: #parameters-10
|
995 |
|
996 | [35]: #examples-10
|
997 |
|
998 | [36]: #isnotvisible
|
999 |
|
1000 | [37]: #parameters-11
|
1001 |
|
1002 | [38]: #examples-11
|
1003 |
|
1004 | [39]: #hasattribute
|
1005 |
|
1006 | [40]: #parameters-12
|
1007 |
|
1008 | [41]: #examples-12
|
1009 |
|
1010 | [42]: #doesnothaveattribute
|
1011 |
|
1012 | [43]: #parameters-13
|
1013 |
|
1014 | [44]: #examples-13
|
1015 |
|
1016 | [45]: #hasaria
|
1017 |
|
1018 | [46]: #parameters-14
|
1019 |
|
1020 | [47]: #examples-14
|
1021 |
|
1022 | [48]: #doesnothavearia
|
1023 |
|
1024 | [49]: #parameters-15
|
1025 |
|
1026 | [50]: #examples-15
|
1027 |
|
1028 | [51]: #hasproperty
|
1029 |
|
1030 | [52]: #parameters-16
|
1031 |
|
1032 | [53]: #examples-16
|
1033 |
|
1034 | [54]: #isdisabled
|
1035 |
|
1036 | [55]: #parameters-17
|
1037 |
|
1038 | [56]: #examples-17
|
1039 |
|
1040 | [57]: #isnotdisabled
|
1041 |
|
1042 | [58]: #parameters-18
|
1043 |
|
1044 | [59]: #examples-18
|
1045 |
|
1046 | [60]: #hasclass
|
1047 |
|
1048 | [61]: #parameters-19
|
1049 |
|
1050 | [62]: #examples-19
|
1051 |
|
1052 | [63]: #doesnothaveclass
|
1053 |
|
1054 | [64]: #parameters-20
|
1055 |
|
1056 | [65]: #examples-20
|
1057 |
|
1058 | [66]: #hasstyle
|
1059 |
|
1060 | [67]: #parameters-21
|
1061 |
|
1062 | [68]: #examples-21
|
1063 |
|
1064 | [69]: #haspseudoelementstyle
|
1065 |
|
1066 | [70]: #parameters-22
|
1067 |
|
1068 | [71]: #examples-22
|
1069 |
|
1070 | [72]: #doesnothavestyle
|
1071 |
|
1072 | [73]: #parameters-23
|
1073 |
|
1074 | [74]: #examples-23
|
1075 |
|
1076 | [75]: #doesnothavepseudoelementstyle
|
1077 |
|
1078 | [76]: #parameters-24
|
1079 |
|
1080 | [77]: #examples-24
|
1081 |
|
1082 | [78]: #hastext
|
1083 |
|
1084 | [79]: #parameters-25
|
1085 |
|
1086 | [80]: #examples-25
|
1087 |
|
1088 | [81]: #hasanytext
|
1089 |
|
1090 | [82]: #parameters-26
|
1091 |
|
1092 | [83]: #examples-26
|
1093 |
|
1094 | [84]: #hasnotext
|
1095 |
|
1096 | [85]: #parameters-27
|
1097 |
|
1098 | [86]: #examples-27
|
1099 |
|
1100 | [87]: #includestext
|
1101 |
|
1102 | [88]: #parameters-28
|
1103 |
|
1104 | [89]: #examples-28
|
1105 |
|
1106 | [90]: #doesnotincludetext
|
1107 |
|
1108 | [91]: #parameters-29
|
1109 |
|
1110 | [92]: #examples-29
|
1111 |
|
1112 | [93]: #hasvalue
|
1113 |
|
1114 | [94]: #parameters-30
|
1115 |
|
1116 | [95]: #examples-30
|
1117 |
|
1118 | [96]: #hasanyvalue
|
1119 |
|
1120 | [97]: #parameters-31
|
1121 |
|
1122 | [98]: #examples-31
|
1123 |
|
1124 | [99]: #hasnovalue
|
1125 |
|
1126 | [100]: #parameters-32
|
1127 |
|
1128 | [101]: #examples-32
|
1129 |
|
1130 | [102]: #matchesselector
|
1131 |
|
1132 | [103]: #parameters-33
|
1133 |
|
1134 | [104]: #examples-33
|
1135 |
|
1136 | [105]: #doesnotmatchselector
|
1137 |
|
1138 | [106]: #parameters-34
|
1139 |
|
1140 | [107]: #examples-34
|
1141 |
|
1142 | [108]: #hastagname
|
1143 |
|
1144 | [109]: #parameters-35
|
1145 |
|
1146 | [110]: #examples-35
|
1147 |
|
1148 | [111]: #doesnothavetagname
|
1149 |
|
1150 | [112]: #parameters-36
|
1151 |
|
1152 | [113]: #examples-36
|
1153 |
|
1154 | [114]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
|
1155 |
|
1156 | [115]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element
|
1157 |
|
1158 | [116]: https://developer.mozilla.org/de/docs/Web/API/Document/querySelector
|
1159 |
|
1160 | [117]: #doesNotExist
|
1161 |
|
1162 | [118]: https://developer.mozilla.org/docs/Web/HTML/Element
|
1163 |
|
1164 | [119]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
1165 |
|
1166 | [120]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
1167 |
|
1168 | [121]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
1169 |
|
1170 | [122]: #isNotChecked
|
1171 |
|
1172 | [123]: #isChecked
|
1173 |
|
1174 | [124]: #isNotFocused
|
1175 |
|
1176 | [125]: #isFocused
|
1177 |
|
1178 | [126]: #isNotRequired
|
1179 |
|
1180 | [127]: #isRequired
|
1181 |
|
1182 | [128]: #isValid
|
1183 |
|
1184 | [129]: #isNotVisible
|
1185 |
|
1186 | [130]: #isVisible
|
1187 |
|
1188 | [131]: #doesNotHaveAttribute
|
1189 |
|
1190 | [132]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp
|
1191 |
|
1192 | [133]: #hasAttribute
|
1193 |
|
1194 | [134]: #hasNoAria
|
1195 |
|
1196 | [135]: #hasAria
|
1197 |
|
1198 | [136]: #doesNotHaveProperty
|
1199 |
|
1200 | [137]: #isNotDisabled
|
1201 |
|
1202 | [138]: #isDisabled
|
1203 |
|
1204 | [139]: #doesNotHaveClass
|
1205 |
|
1206 | [140]: https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
|
1207 |
|
1208 | [141]: #hasClass
|
1209 |
|
1210 | [142]: https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
|
1211 |
|
1212 | [143]: #includesText
|
1213 |
|
1214 | [144]: https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
|
1215 |
|
1216 | [145]: #hasText
|
1217 |
|
1218 | [146]: #hasNoText
|
1219 |
|
1220 | [147]: #hasAnyValue
|
1221 |
|
1222 | [148]: #hasNoValue
|
1223 |
|
1224 | [149]: https://developer.mozilla.org/docs/Web/API/HTMLInputElement
|
1225 |
|
1226 | [150]: #hasValue
|
1227 |
|
1228 | [151]: https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName
|