N
Nuxt4w ago
Leo

Vitest not running in Docker Container.

Hey, I'm trying to run my tests inside a Docker Container using a Github action. If I try to run it outside of it, everything works fine, but if I run it inside a container, it is stuck at the point where the console logs:
RUN v2.1.5 /__w/daytistics/daytistics/frontend
RUN v2.1.5 /__w/daytistics/daytistics/frontend
2 Replies
kapa.ai
kapa.ai4w ago
Hi @Leo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, it seems that you're encountering an issue with Vitest hanging during the build process in a Docker container. This is a known issue that has been reported by others as well. Here's what we can gather from the available information: 1. The problem appears to be related to building Nuxt applications in a Linux Docker environment. As mentioned in a Stack Overflow post (https://stackoverflow.com/questions/77517718), a similar issue was encountered where the build process hangs indefinitely when using the --platform linux/amd64 option. 2. The solution that worked for the person in that Stack Overflow post was to switch from docker build to docker buildx build. This might be worth trying in your case as well. 3. It's also worth noting that debugging Nuxt applications inside Docker can be challenging. As mentioned in the Nuxt documentation on debugging (https://nuxt.com/docs/guide/going-further/debugging#debugging-with-node-inspector), "Note that the Node.js and Chrome processes need to be run on the same platform. This doesn't work inside of Docker." 4. Another potential issue could be related to the configuration of your Nuxt application to accept connections from outside the host machine. As suggested in another Stack Overflow answer (https://stackoverflow.com/questions/77046323), you might need to set the HOST environment variable or configure it in your nuxt.config.js:
server: {
port: 3000,
host: '0.0.0.0' // do not put localhost (only accessible from the host machine)
}

server: {
port: 3000,
host: '0.0.0.0' // do not put localhost (only accessible from the host machine)
}

5. Lastly, ensure that your Vitest configuration is correct. The Nuxt documentation on testing (https://nuxt.com/docs/getting-started/testing#unit-testing) mentions that when importing @nuxt/test-utils in your Vitest config, it's necessary to have "type": "module" specified in your package.json or rename your Vitest config file appropriately (e.g., vitest.config.mts or vitest.config.mjs). Given the complexity of the issue and the limited information available, it might be helpful to try these suggestions and see if they resolve the problem. If the issue persists, you may need to provide more details about your specific setup and configuration for further troubleshooting. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4w ago
<@809685585374740480> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Want results from more Discord servers?
Add your server