Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testcafe Vue Selectors can't grab Vue component

I'm using Testcafe Vue Selectors to perform e2e testing on my Vue application but it looks like I can't grab any of my components:

1) An error occurred in getVue code:

      TypeError: Cannot read property '__vue__' of undefined

This is a sample test I have created:

import VueSelector from "testcafe-vue-selectors";
import { Selector } from 'testcafe';

fixture `Getting Started`
    .page `http://localhost:8081/`;

test('test totalValue format', async t => {
    const totalValue = VueSelector("total-value");

    await t
        .click("#total-value-toggle-format")
        .expect(totalValue.getVue(({ props }) => props.formatProperty)).eql(null)
});

The structure of my components tree is the following:

Root
|___App
    |___Hello
        |___TotalValue

And I import the component like this:

  "total-value": TotalValue,

Why is this not working?

EDIT: this is the page where I test the component

<template>
    <div class="hello">
        <div class="component-wrapper">
              <total-value
                  :value="totalValueValue"
                  :formatProperty="computedFormatNumber">
              </total-value>
        </div>
    </div>
</template>

<script>   
import TotalValue from "../../core/TotalValue";

export default {
    name: "hello",
    components: {
        "total-value": TotalValue,
    },
    data() {
        return {
            totalValueValue: 1000000,
            formatNumber: true,
            formatFunction: Assets.formatNumber,
        };
    },
    computed: {
        computedFormatNumber() {
            return this.formatNumber ? ["nl", "0,0 a"] : [];
        },

    },
};
like image 746
ste Avatar asked Nov 08 '22 20:11

ste


1 Answers

Just a follow-up, we have fixed the issue described in this thread:

Support component loaded via vue-loader

like image 159
Alex Skorkin Avatar answered Nov 14 '22 21:11

Alex Skorkin