GithubHelp home page GithubHelp logo

Broken with Vitest 0.32.0 about docs HOT 9 CLOSED

vite-pwa avatar vite-pwa commented on September 28, 2024
Broken with Vitest 0.32.0

from docs.

Comments (9)

userquin avatar userquin commented on September 28, 2024 1

rn you cannot test service workers in Vitest, and @vitest/browser still experimental...

from docs.

doutatsu avatar doutatsu commented on September 28, 2024 1

The latest Vitest version (0.33) doesn't have an issue anymore. Not sure what change they made, but this is not an issue anymore

from docs.

userquin avatar userquin commented on September 28, 2024

can you try adding v-if="!import.meta.vitest" to the component?

<BaseReloadPrompt v-if="!import.meta.vitest"....

from docs.

doutatsu avatar doutatsu commented on September 28, 2024

I am not testing them in vitest, rather it just gets imported automatically across all tests, as it's a base component. But I'll give it a go with v-if as I am not testing it

from docs.

userquin avatar userquin commented on September 28, 2024

ok, you can check examples/vue-router in vite-plugin-pwa, I'll test it with latest Vitest... you have a build and browser tests with Vitest and PlayWright respectivelly.

from docs.

doutatsu avatar doutatsu commented on September 28, 2024

Yeah, I can't just do v-if and I am not interested in browser tests. I think I need to just adjust my auto-imports to ignore this component in vitest environment

Edit: It's actually not the auto-loading plugin I made. I am not importing this component at all now and I am still getting an error.

from docs.

userquin avatar userquin commented on September 28, 2024

Maybe you can use defineAsyncComponent doing the check inside the resolver returning undefined, avoid registering the component globally (auto-import or similar libs).

I have all tests working on my local (vite-plugin-pwa), I haven't sent the PR yet to bump dependencies...

imagen

from docs.

userquin avatar userquin commented on September 28, 2024

I guess you're testing your app with @vue/test-utils, maybe you can create a functional ts/js component, rendering the component inside the setup, something like this:

// src/components/base_components/BaseWrapperReloadPrompt.ts
import { defineComponent, h } from 'vue'

export const BaseWrapperReloadPrompt = defineComponent({
  async setup(props) {
    if (import.meta.vitest)
      return {}

    const component = await import('./BaseReloadPrompt.vue')
    return () => h(component.default ?? component, props)
  },
})

from docs.

userquin avatar userquin commented on September 28, 2024

thx for reporting @doutatsu

from docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.