jeudi 8 avril 2021

Getting access to varaibles when testing Vue with Jest

I am using the structure below in my Vuejs web application. I am now trying to implement testing to it. But when trying to test the exampleOfFunction it says that this.exampleOfData2 is undefined.

<template>
      *Some HTML*
</template>

<script>
    *Some Imports*
export default {
    data() {
        return {
            exampleOfData1: [],
            exampleOfData2: 100
     },
        methods: {
        exampleOfFunction:function(){
            if(this.exampleOfData2 === 100)
            {
                return false;
            }
            return true;
        },
    created() {
    },
    mounted() {
    }

When I do console.log(FileToTest.data()); I can see the values and I can access the function with FileToTest.methods.exampleOfFunction(); but when I do it says that this.exampleOfData2 is undefined.

Aucun commentaire:

Enregistrer un commentaire