Download free for 30 days
Sign in
Upload
Language (EN)
Support
Business
Mobile
Social Media
Marketing
Technology
Art & Photos
Career
Design
Education
Presentations & Public Speaking
Government & Nonprofit
Healthcare
Internet
Law
Leadership & Management
Automotive
Engineering
Software
Recruiting & HR
Retail
Sales
Services
Science
Small Business & Entrepreneurship
Food
Environment
Economy & Finance
Data & Analytics
Investor Relations
Sports
Spiritual
News & Politics
Travel
Self Improvement
Real Estate
Entertainment & Humor
Health & Medicine
Devices & Hardware
Lifestyle
Change Language
Language
English
Español
Português
Français
Deutsche
Cancel
Save
Submit search
EN
Uploaded by
Joe_noh
PDF, PPTX
4,683 views
Vue.jsのユニットテスト
エムスリー tech talk でお話した資料です。
Technology
◦
Read more
5
Save
Share
Embed
Embed presentation
Download
Download as PDF, PPTX
1
/ 27
2
/ 27
3
/ 27
4
/ 27
5
/ 27
6
/ 27
7
/ 27
8
/ 27
9
/ 27
10
/ 27
11
/ 27
12
/ 27
13
/ 27
14
/ 27
15
/ 27
16
/ 27
17
/ 27
18
/ 27
19
/ 27
20
/ 27
21
/ 27
22
/ 27
23
/ 27
24
/ 27
25
/ 27
26
/ 27
27
/ 27
More Related Content
PPT
Web App Mvc
by
Will Gunn
ODP
Jquery Plugin
by
Simone Gentili
DOC
Correcion
by
diegorap
TXT
Zadatak
by
Zeljko Lukic
PDF
Underscore.js
by
Sebastian Motraghi
TXT
Base datos
by
Alexander Centeno Quirós
PPTX
Peggy optimist
by
LearningTech
KEY
JavaScript Tips
by
裕介 藤木
Web App Mvc
by
Will Gunn
Jquery Plugin
by
Simone Gentili
Correcion
by
diegorap
Zadatak
by
Zeljko Lukic
Underscore.js
by
Sebastian Motraghi
Base datos
by
Alexander Centeno Quirós
Peggy optimist
by
LearningTech
JavaScript Tips
by
裕介 藤木
More from Joe_noh
PDF
リーンキャンバス
by
Joe_noh
PDF
Web開発研修イントロダクション
by
Joe_noh
PDF
Vuexと入力フォーム
by
Joe_noh
PDF
Webオペレーション研修イントロダクション
by
Joe_noh
PDF
パフォーマンス改善のためにやったこと・やらなかったこと
by
Joe_noh
PDF
Elixirだ 第1回強化版 後半
by
Joe_noh
PPTX
できないことはPortで外注
by
Joe_noh
PDF
Elixirだ 第2回
by
Joe_noh
PDF
もっとgit
by
Joe_noh
PDF
Elixirだ 第1回強化版 前半
by
Joe_noh
PDF
やってみた -URL外形監視-
by
Joe_noh
PDF
DBにseedするライブラリつくった
by
Joe_noh
PDF
カラーミーAPIドキュメントの今後
by
Joe_noh
PDF
Elixirだ 第3回
by
Joe_noh
PDF
Elixirだ 第6回
by
Joe_noh
PDF
Elixirだ 第5回
by
Joe_noh
PDF
Elixirだ 第4回
by
Joe_noh
PDF
モバイルアプリ研修イントロダクション
by
Joe_noh
PDF
お産ウィークイントロダクション
by
Joe_noh
PDF
サイクルOJTイントロダクション
by
Joe_noh
リーンキャンバス
by
Joe_noh
Web開発研修イントロダクション
by
Joe_noh
Vuexと入力フォーム
by
Joe_noh
Webオペレーション研修イントロダクション
by
Joe_noh
パフォーマンス改善のためにやったこと・やらなかったこと
by
Joe_noh
Elixirだ 第1回強化版 後半
by
Joe_noh
できないことはPortで外注
by
Joe_noh
Elixirだ 第2回
by
Joe_noh
もっとgit
by
Joe_noh
Elixirだ 第1回強化版 前半
by
Joe_noh
やってみた -URL外形監視-
by
Joe_noh
DBにseedするライブラリつくった
by
Joe_noh
カラーミーAPIドキュメントの今後
by
Joe_noh
Elixirだ 第3回
by
Joe_noh
Elixirだ 第6回
by
Joe_noh
Elixirだ 第5回
by
Joe_noh
Elixirだ 第4回
by
Joe_noh
モバイルアプリ研修イントロダクション
by
Joe_noh
お産ウィークイントロダクション
by
Joe_noh
サイクルOJTイントロダクション
by
Joe_noh
Vue.jsのユニットテスト
2.
• Joe_noh Joe-noh
5.
<template> <p>Hello, {{name}}</p> </template> <script> export default
{ props: { name: String } } </script> <style scoped></style>
6.
describe(’MyComponent’, () =>
{ const Ctor = Vue.extend(MyComponent) it(’says Hello’, () => { const propsData = {name: ’Bob’} const vm = new Ctor({propsData}).$mount() expect(vm.$el.textContent).to.contain(’Hello, Bob’) }) })
8.
import {mount} from
‘vue-test-utils’ describe(’MyComponent’, () => { it(’says Hello’, () => { const propsData = {name: ’Bob’} const wrapper = mount(MyComponent, {propsData}) expect(wrapper.text()).to.contain(’Hello, Bob’) }) })
9.
const wrapper =
mount(MyComponent, {propsData}) wrapper.text() wrapper.html() wrapper.trigger(‘click’) wrapper.find(‘input#name’).trigger(‘input’) wrapper.emitted() wrapper.setData({foo: ‘bar’}) wrapper.vm.$el
11.
mount(Component).html() <div id=“parent”> <div class=“foo”> … </div> <kodomo-component
/> </div> shallow(Component).html() <div id=“parent”> <div class=“foo”> … </div> <!-- --> </div>
13.
const wrapper =
mount(MyComponent, {propsData}) describe(‘when API returns errors’, () => { it(‘shows error message’, () => { sinon.stub(ApiClient, ’request’).rejects(error) wrapper.find(‘#submit-button’).trigger(‘click’) expect(wrapper.text()).to.contain(‘やばい’) }) }) //=> Fail
14.
<button id=”submit-button” @click=“submit”>送信</button> async
submit() { try { await ApiClient.request(params) } catch (error) { this.showError(error.message) } }
15.
const wrapper =
mount(MyComponent, {propsData}) describe(‘when API returns errors’, async () => { it(‘shows error message’, () => { sinon.stub(ApiClient, ’request’).rejects(error) wrapper.find(‘#submit-button’).trigger(‘click’) await Vue.nextTick() expect(wrapper.text()).to.contain(‘やばい’) }) }) //=> Success!
16.
wrapper.find(‘#submit-button’).trigger(‘click’) await Vue.nextTick() await Vue.nextTick() await
Vue.nextTick() expect(wrapper.text()).to.contain(‘やばい’)
17.
Vue.use(VueRouter) //=> Vue.prototype をイジるためグローバルに影響がある
18.
Vue.use(VueRouter) //=> Vue.prototype をイジるためグローバルに影響がある Object.defineProperty(Vue.prototype,
'$router', { get () { return this._routerRoot._router } }) Object.defineProperty(Vue.prototype, '$route', { get () { return this._routerRoot._route } })
19.
Vue.use(VueRouter) //=> Vue.prototype をイジるためグローバルに影響がある //=>
$routerと$routeがモックできなくなる mount(MyComponent, { mocks: { $route: {query: {number: 42}} } }) // setting a property that has only a getter
20.
import {createLocalVue} from
‘vue-test-utils’ const localVue = createLocalVue() localVue.use(VueRouter) mount(MyComponent, { localVue: localVue, mocks: { $route: { query: {number: 42} } } })
21.
Vue.use(VueRouter)
24.
https://github.com/storybooks/storybook/blob/master/addons/storyshots/docs/storyshots-fail.png
Download