Last active
May 12, 2017 08:26
-
-
Save johnnynotsolucky/22e26aaf7a8a42691fecbcf169c7d569 to your computer and use it in GitHub Desktop.
Test Vue components with html-looks-like
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Vue = require('vue') | |
module.exports = Vue.extend({ | |
template: ` | |
<div> | |
<h1>Hello</h1> | |
<h2>{{name}}</h2> | |
</div> | |
`, | |
props: { name: String } | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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