Vue Test Utils 要素の属性値を取得する
Vue Test Utils 要素の属性値を取得する
やりたいこと
例えば、このようなコンポーネントをテストするときに属性値を取得する。
テスト対象.vue
<customComponent>
v-model="input"
label="メールアドレス"
type="Email"
place-holder="[email protected]"
:content="formEmail"
></customComponent>
やり方
以下のようでlabel属性の値を取得できる。
__test__/テスト対象.spec.js
import { Mount } from '@vue/test-utils'
import Component from '~/pages/テスト対象.vue' // Nuxtのディレクトリ構造前提
...
wrapper = Mount(Component)
describe('テスト対象.vueのテスト', () => {
test('属性値の取得', () => {
expect(wrapper.find('[type=password]').attributes().label).toBe(
'パスワード'
)
})
...
Author And Source
この問題について(Vue Test Utils 要素の属性値を取得する), 我々は、より多くの情報をここで見つけました https://qiita.com/AtsushiEsashika/items/4f215980dd286cf99a42著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .