No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Unit testing a component with QPageSticky

    Help
    qpagesticky test
    1
    1
    419
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      arfarf last edited by arfarf

      I’m trying to write a test using jest for a component that looks like this:

      <template>
        <q-page-sticky
          position="top"
          expand
          class="bg-secondary text-base"
        >
          <q-toolbar dense>
            <q-btn
              v-if="hasBackBtn"
              flat
              round
              dense
              icon="chevron_left"
            />
            ...
          </q-toolbar>
        </q-page-sticky>
      </template>
      

      Mounting this component in test logs out QPageSticky needs to be child of QLayout error in console.

      describe('Foo.vue', () => {
        const localVue = createLocalVue();
        localVue.use(Quasar, { components });
        // error in mount
        const wrapper = mount(Foo, {
          localVue,
          propsData: {
            hasBackBtn: false,
            title: 'Title',
          },
        });
        const { vm } = wrapper;
        ...
      

      Making a temporary component and passing it to parentComponent field in mount() still didn’t work.

      const parentQLayout = {
        name: 'parentQLayout',
        template: '<q-layout></q-layout>',
      };
      
      describe('Foo.vue', () => {
        const localVue = createLocalVue();
        localVue.use(Quasar, { components });
      
        const wrapper = mount(Foo, {
          localVue,
          parentComponent: parentQLayout,
          propsData: {
            hasBackBtn: false,
            title: 'Title',
          },
        });
        const { vm } = wrapper;
      

      This component is used inside parent component that has QLayout in actual source code btw. Is there any way to test a component with QPageSticky independently given its QLayout restriction?

      1 Reply Last reply Reply Quote 0
      • First post
        Last post