Skip to content

Get deprecated notification while using findAll() on html/css selector (no Vue component) #1703

Closed
@kuehnleon

Description

@kuehnleon

Subject of the issue

It is not possible to run findAll() without getting the deprecation notice:

finding components with `findAll` is deprecated and will be removed in the next major version. Use `findAllComponents` instead.

But it is not possible to use findAllComponents() if the wrapper is a non-vue component.

You will receive the following error:

Error: [vue-test-utils]: You cannot chain findAllComponents off a DOM element. It can only be used on Vue Components.
    at throwError (dist/js/webpack:/node_modules/@vue/test-utils/dist/vue-test-utils.js:1700:1)
    at Wrapper.findAllComponents (dist/js/webpack:/node_modules/@vue/test-utils/dist/vue-test-utils.js:10529:1)
    at Context.<anonymous> (dist/js/webpack:/tests/unit/tenant/tests/migration-job-list.spec.js:87:1)
    at processImmediate (internal/timers.js:456:21)

Steps to reproduce

notice: I'm using mocha and chai-should

import {createLocalVue, shallowMount} from '@vue/test-utils';

let localVue;
localVue = createLocalVue();

it("test rows of table", () => {
  wrapper = shallowMount(MyComponent, {
      localVue
  });

  const table = cardBody.find("table");
  table.exists().should.equal(true);

  const rows = table.findAllComponents(TableRow);
  rows.length.should.equal(3);
});

Expected behaviour

const rows = table.findAllComponents(TableRow) should return a WrapperArray containing all TableRow components.

OR

const rows = table.findAll(TableRow) should return a WrapperArray containing all TableRow components without display a deprecation notice.

Actual behaviour

receiving an error:

Error: [vue-test-utils]: You cannot chain findAllComponents off a DOM element. It can only be used on Vue Components.
    at throwError (dist/js/webpack:/node_modules/@vue/test-utils/dist/vue-test-utils.js:1700:1)
    at Wrapper.findAllComponents (dist/js/webpack:/node_modules/@vue/test-utils/dist/vue-test-utils.js:10529:1)
    at Context.<anonymous> (dist/js/webpack:/tests/unit/tenant/tests/migration-job-list.spec.js:87:1)
    at processImmediate (internal/timers.js:456:21)

Possible Solution

Don't show deprecation notice if you're using findAll() on non-vue component.

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