Giter Club home page Giter Club logo

vue3-class-sfc-test's People

Contributors

tinobino avatar

Watchers

 avatar

vue3-class-sfc-test's Issues

Tests using mixins

Hi there! I saw your comment in the vue-property-decorator issue, I'm currently struggling with unit tests for class components as well.

I also found that importing 'Vue' from 'vue-class-component' works, but only if you extend from it directly, so for instance this also fails:

<template>
  <h1>ClassMain</h1>
  <ClassChild />
  {{ message }}
  {{ greeting }}
</template>

<script lang="ts">
import ClassChild from "@/components/ClassChild.vue";
import TestMixin from "@/mixins/TestMixin.vue";
import { Options as Component, Vue, mixins } from "vue-class-component";

@Component({
  components: {
    ClassChild,
  },
})
export default class ClassMain extends mixins(TestMixin) {
  greeting = "Howdy!";
}
</script>

The mixin looks like this:

<script lang="ts">
import { Vue } from "vue-class-component";

export default class TestMixin extends Vue {
  message = "Hello world!";
}
</script>

This results in 3 warnings:

[Vue warn]: Failed to resolve component: ClassChild 
  at <Anonymous ref="VTU_COMPONENT" > 
  at <VTUROOT>
[Vue warn]: Property "message" was accessed during render but is not defined on instance. 
  at <Anonymous ref="VTU_COMPONENT" > 
  at <VTUROOT>
[Vue warn]: Property "greeting" was accessed during render but is not defined on instance. 
  at <Anonymous ref="VTU_COMPONENT" > 
  at <VTUROOT>

I have no idea why this happens but I can't find many people that are having this issue so I thought it would atleast be good if you knew that it is not only happening with sub components. Basically anything you define in your class will not be available in a unit test if you dont extend Vue (which is imported from class-component) directly.

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.