Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

306
Views
Jest Vue: Is it possible to load dynamic imports for snapshot?

I'm trying to unit test a Vue component that dynamically loads it's child component. The problem is that Jest / Vue utils doesn't seem to be able to render it. Is there any way of doing this?

My component

<template>
  <component :is="component" v-bind="props" />
</template>

<script>
const components = {
  dog: () => import('./dog.vue'),
  cat: () => import('./cat.vue')
}

export default {
  props: { type: String }

  computed: {
    component() {
      return components[this.type]
    }

    props() { ... }
  }
}
</script>

This is my test

...
it('renders correctly', async () => {
  const wrapper = mount(Component, { ... })

  expect(wrapper.element).toMatchSnapshot()
})
...

And this is the resulting snapshot file

// Jest Snapshot v1

exports[`Markdown Token renders correctly 1`] = `<!---->`;

Thanks in advance :)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!