鈍足ランナーのIT日記

走るのが好きな5流のITエンジニアのブログ。

趣味の範囲は広いけど、どれも中途半端なクソブロガー楽しめるWebアプリを作ってあっと言わせたい。サーバーサイドPerl(Mojolicious)、クライアントサイドVue.js。Arduinoにも触手を伸ばす予定。

vueをテストする

インストール方法

npm install --save-dev @vue/test-utils

記述

import { shallow } from '@vue/test-utils'
import Vue from 'vue'
import Vuetify from 'vuetify'
import Menu from '@/components/Menu'
import VueI18n from 'vue-i18n'

Vue.use(Vuetify)
Vue.use(VueI18n)

const data = require('../../../src/i18n/message.json')

const i18n = new VueI18n({
  locale: 'ja',
  messages: data
})

describe('Menu.vue', () => {
  it('should render correct contents', () => {
    const wrapper = shallow(Menu, {i18n})
    expect(wrapper.text())
      .to.contain('割引/ポイント')
    expect(wrapper.text())
      .to.contain('軽快な操作性')
    expect(wrapper.text())
      .to.contain('PWA')
  })
})