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
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”
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
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?
I’m trying to embed a Twitch player on a website using Vue 2 with Nuxt. A minimal component would look like this: I imported the Twitch js file in the head element in nuxt.config.js. The player works fine as long as the scope is within the setupPlayer() method. Once I try to assign the tempPlayer object to this.player (to access
I am trying to use Nuxt.js Content in my project. The problem is that when I try to use $content method in my project the TypeError: _this.$content is not a function occurs: I imported the @nuxt/content in Nuxt config and in typescript config. nuxt.config.js tsconfig.json Answer Nuxt content v2 needs Nuxt3. If you’re using Nuxt2, you should use the v1.
Currently , i am doing an end to end testing in my nuxt project. I want to test the frontend of my project to ensure the UI is presentable and clickable. However , I am facing a problem for my button. It felt like button is not clicked. I am pretty sure the css selector for my button is correctly
I am using the map function with an if statement that doesn’t end in else. I have to be strict that only the defined recourseTypes are shown. in eslint I get an error on my => as it doesn’t end in an else Array.prototype.map() expects a value to be returned at the end of arrow function. Is there a correct
I have a Nuxt SSR app which need to open new window on link click, but new window does not have actual data in the store. There are only default values. How can I share actual values in the store between this two pagaes? This is the code of new page which ask for currency value: Answer Yes, if you
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