Skip to content

Instantly share code, notes, and snippets.

@johnnynotsolucky
Last active May 12, 2017 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnnynotsolucky/22e26aaf7a8a42691fecbcf169c7d569 to your computer and use it in GitHub Desktop.
Save johnnynotsolucky/22e26aaf7a8a42691fecbcf169c7d569 to your computer and use it in GitHub Desktop.
Test Vue components with html-looks-like
const Vue = require('vue')
module.exports = Vue.extend({
template: `
<div>
<h1>Hello</h1>
<h2>{{name}}</h2>
</div>
`,
props: { name: String }
})
const htmlLooksLike = require('html-looks-like')
const Hello = require('./Hello')
const createVm = name => new Hello({
propsData: { name }
})
describe('Hello', () => {
it('renders an arbitrary name', () => {
const vm = createVm('Human')
const expected = name => `
<div>
{{ ... }}
<h2>${name}</h2>
</div>
`
vm.$mount()
htmlLooksLike(vm.$el.outerHTML, expected('Human'))
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment