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

    Mocking notify plugin in a test

    Help
    2
    3
    803
    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.
    • D
      dariosalvi last edited by

      Hello,

      I have a jest unit test of a component that uses the notify plugin. If import the plugin into the test with:

      import { Notify } from 'quasar'
      

      and then:

      localVue.use(Quasar, { components, plugins: [Notify] })
      

      I get an annoying warning on the console:

      [Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'fullscreen' of undefined"
      

      I am sure it’s the notify plugin because if I remove the plugin the message goes away.

      Even if the test works, I’d like to get rid of the warning message, so I was wondering if there is a good way to mock the notiify plugin. I’ve tried with the following mock but it’s clearly wrong:

      const Notify = {
        notify () {
          console.log('notify')
        }
      }
      

      Have you got any tip to share?
      Thanks!

      metalsadman 1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman @dariosalvi last edited by

        @dariosalvi you should also ask this in the testing channel in our discord.

        1 Reply Last reply Reply Quote 0
        • D
          dariosalvi last edited by

          I have found a solution to the specific warning: the reference to fullscreen is inside the function mounted() of the Notify plugin.

          I have mocked mounted() with:

            Notify.mounted = () => {
              return jest.fn()
            }
          

          and the warning has disappeared.

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