Test if Element exists Vuejs, Karma, Mocha
<p>I'm new to testing in Javascript and Vue.js.  I installed vue via vue-cli and the full webpack template that has Karma, Mocha, and PhantomJS built in. I ran the hello world component test and it passes.  </p>

<p>I have a vuejs component called <code>my-input.vue</code> that generates the following HTML.</p>

<pre><code>&lt;template&gt;
  &lt;div&gt;
    &lt;input class="test-focused"&gt;
  &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
  export default {

  }
&lt;/script&gt;
</code></pre>

<p>I have a test for the component that looks like this.</p>

<pre><code>import Vue from 'vue'
import { default as MyInput } from 'src/components/my-input.vue'

describe('my-input.vue', () =&gt; {
  it('should display an input element', () =&gt; {
    const expected = "&lt;input class='test-focused'&gt;"

    const vm = new Vue({
      template: '&lt;div&gt;&lt;my-input&gt;&lt;/my-input&gt;&lt;/div&gt;',
      components: { 'my-input': MyInput }
    }).$mount()

    // I tried these separately.
    expect(vm.$el.querySelector('input.test-focused').isPresent()).to.be.true

    expect(document.getElementsByTagName('input').indexOf(expected) != -1).to.be.true
  })
})
</code></pre>

<p>When I run the each of the expect() statements separately I get <code>undefined is not a constructor</code>.</p>

<p>It seems like this is a dirt simple test. </p>

<p><strong>How do I properly test for the existence of an element?</strong></p>

<p>Also, if you can point me to documentation about what methods are available for <code>vm.$el.querySelector('input.test-focused')</code>, as well as, <code>expect()</code> it would help. Disambiguating syntax for Jasmine, Mocha, and other beverages seems to make testing harder than it needs <code>toBe()</code> or <code>not.to.be</code>.  </p>