[Vuejs]-How to create unit test cases with Vue, Karma, browserify

0👍

Hellocomponent

export default {
  name: 'hello',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      test: 'Testing'
    }
  }
}

Hello.spec.js //for testing Hello.vue

describe('Hello', () => {
  it('set correct default data', () => {
    expect(typeof Hello.data).to.equal('function')
    assert.typeOf(Hello.data, 'function')
    const defaultdata = Hello.data()
    expect(defaultdata.test).to.be.a('string')
    expect(defaultdata.test).to.equal('Testing')
  })
})

This is test case of Hello component of vue.js which is created automatically when new template is created. This is using Karma+Mocha+Chai.

Leave a comment