Skip to content

Commit 6bc105e

Browse files
committed
docs: add alternative to hasAttribute
1 parent 6a7ed80 commit 6bc105e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

docs/en/api/wrapper/hasAttribute.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,19 @@ import Foo from './Foo.vue'
1919

2020
const wrapper = mount(Foo)
2121
expect(wrapper.hasAttribute('id', 'foo')).to.equal(true)
22-
```
22+
```
23+
24+
- **Alternative:**
25+
26+
You could get the attribute from the `Wrapper.element` to have a value based assertion:
27+
28+
```js
29+
import { mount } from 'vue-test-utils'
30+
import { expect } from 'chai'
31+
import Foo from './Foo.vue'
32+
33+
const wrapper = mount(Foo)
34+
expect(wrapper.element.getAttribute('id')).to.equal('foo')
35+
```
36+
37+
This makes for a more informative assertion error.

0 commit comments

Comments
 (0)