Skip to content
Advertisement

Tag: nuxt.js

Vitest mock modules function in only one test and use the actual function in others

The following is an abstraction of my problem and thus does not make too much sense: Given I have a simple utility callMethodIf that’s returning the return of another imported method (blackbox). ~~/utils/call-method-if.js: ~~/utils/blackbox.js: How would I run one test case which calls the actual implementation of blackbox() and another one where I mock the return value of blackbox()? I

Import statements breaks script setup Nuxtjs 3

It seems that when I’m using the import statement in the <script setup> all code below it stops working. I installed the @heroicons package and use the import statement to use it as a component in my <template>. But everything below the import statements does not work anymore. My code: When running the code above I do not see “username”

NuxtJS automatically adds script at the end of the body

I’m a newbie NuxtJS programmer. I just searched all over the internet but couldn’t find the answer. I’m just wondering that is it natural that NuxtJS automatically adds the script at the end of the body described as below. Everytime I change my page, it keeps adding this script, so it stacks the same script over and over. Do you

How to use both props and mounted() with NuxtJS?

I’m new to NuxtJS and I’d want to use window.addEventListener on a particular component used on my page, but also remove the event when we change the page. In React, I’d do something like this: But, how do I do the same behaviour with NuxtJS 3? The problem is how do I remove the event once the component will unmount?

How to access Nuxt context inside of fetch() hook?

I want to access the props inside the async fetch() but I’m also using async fetch(context). So, I’m not sure how to access the props. Answer In Nuxt 2, you have 2 fetch hooks. The old one, before Nuxt 2.12, fetch(context) which acts a lot like asyncData. It’s executed before the component creation, so you don’t have access to it

Advertisement