반응형
나는 심판 vue 시험 utils를 사용하여 전자 요소를 선택할 수 있다.
만약 이미지를 가지고 있다.
<img class="pineapple" ref="pineapple" src="pineapple.jpg" />
나는달러 메일 박스를 사용할 수 있거든
expect(wrapper.find($refs.pineapple).exists()).toBe(true)
대신
expect(wrapper.find('.pineapple').exists()).toBe(true)
수 요.wrapper.find
께 the와 ref
★★★★★★★★★★★★★★★★★★.
expect(wrapper.find({ref: 'pineapple'}).exists()).toBe(true)
그 뷰 시험 util 도움말:부터.
옵션 개체를 찾아라
휴식
발굴품 옵션 개체를 사용하여 뷰 시험 Utils달러의 래퍼 요소 요소에 선택을 허용하고 있다.
const buttonWrapper = wrapper.find({ ref: 'myButton' })
buttonWrapper.trigger('click')
https://vue-test-utils.vuejs.org/api/selectors.html
언급URL:https://stackoverflow.com/questions/55455763/can-i-select-an-element-by-ref-using-vue-test-utils
반응형
'programing' 카테고리의 다른 글
오류: PostCSS 플러그인을 로드하지 못했습니다. 'postcss-import' 모듈을 찾을 수 없습니다(Vue 2). (0) | 2022.08.30 |
---|---|
Java GUI 프레임워크뭘 고를까?Swing, SWT, AWT, SwingX, JGodies, JavaFX, Apache Pivot? (0) | 2022.08.30 |
read()와 fread()의 차이점은 무엇입니까? (0) | 2022.08.23 |
Vuex - http 서버에서 스토어 데이터를 로드/초기화하는 시기 (0) | 2022.08.23 |
[Vue warn] :상위 구성 요소가 다시 렌더링될 때마다 값이 덮어쓰기되므로 프로펠을 직접 변환하지 마십시오. (0) | 2022.08.23 |