Skip to content

While testing out mixins, the $refs cannot be modified and due to which the testing cannot occur. #2098

Open
@shivamp-argus

Description

@shivamp-argus

When tesing out the mixin, $refs is empty object and cannot be modified.
` import { shallowMount } from '@vue/test-utils';
import AcWidgetMixin from './ac-widget-mixin';

let widgetUuid = '98FADB82-E2AA-4A74-8460-39DF28365435';

function getWrapper() {
const Component = {
render() {},
mixins: [AcWidgetMixin]
};
return shallowMount(Component, {
props: { widgetUuid, totalRecords: 8 }
});
}
let wrapper;

describe('Ac-widget Mixin', () => {
describe('getTableHeight', () => {
describe('when data-table is present', () => {
beforeEach(async () => {
wrapper = getWrapper();
wrapper.vm.$refs.tableRef = { $el: { clientHeight: 1600 } };
});

  afterEach(() => wrapper.unmount());

  it('Should return clientHeight of element when method is called', () => {
    expect(wrapper.vm.getTableHeight()).toBe(1600);
  });
});

});
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions