title: How to unit test standalone Vue composition
body: <p>I have a setup similar as <a href="https://vue-composition-api-rfc.netlify.com/#logic-extraction-and-reuse" rel="noreferrer">the example in the docs</a> where my <em>composition</em> lives in a separate file from my component as follows:</p>
  
  <pre class="lang-js prettyprint-override"><code>// composition.js
  import { onMounted } from '@vue/composition-api';
  
  export default function useComposition() {
    onMounted(() =&gt; {
      console.log('Hello, world!');
    });
  }
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>// component.vue
  &lt;template&gt;...&lt;/template&gt;
  
  &lt;script&gt;
  import { createComponent } from '@vue/composition-api';
  
  export default createComponent({
    setup() {
      useComposition();
    }
  })
  &lt;/script&gt;
  </code></pre>
  
  <p>I would like to write a separate (Jest based) test file for just the <code>composition.js</code> file. However, when calling the composition directly, Vue will error out (expectedly):</p>
  
  <pre class="lang-js prettyprint-override"><code>// composition.test.js
  
  import useComposition from './composition';
  
  describe('Composition', () =&gt; {
    it('Works', () =&gt; {
      useComposition();
      // Error: [vue-composition-api] "onMounted" get called outside of "setup()"
    });
  });
  </code></pre>
  
  <p>I've tried mounting a mock composition API based component in order to provide a <code>setup()</code> function, but having some trouble getting it to work:</p>
  
  <pre class="lang-js prettyprint-override"><code>import { mount, createLocalVue } from '@vue/test-utils';
  import VueCompositionAPI, { createComponent } from '@vue/composition-api';
  import useComposition from './composition';
  
  const localVue = createLocalVue();
  localVue.use(VueCompositionAPI);
  
  describe('Composition', () =&gt; {
      it('Works', () =&gt; {
          const mockComponent = createComponent({
              setup() {
                  useComposition();
  
                  return h =&gt; h('div');
              }
          });
  
          mount(mockComponent, { localVue });
          // [Vue warn]: Failed to mount component: template or render function not defined.
      });
  });
  </code></pre>
  
  <p>Does anybody have any bright ideas on how to get this to work so I can write tests for my modular compositions?</p>