question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

createTest from @nuxt/test-utils-edge can't load nuxt

See original GitHub issue

Environment

Nuxt CLI v3.0.0-rc.6 17:34:51 RootDir: /app 17:34:53 Nuxt project info: 17:34:53


  • Operating System: Linux
  • Node Version: v14.20.0
  • Nuxt Version: 3.0.0-rc.6
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: srcDir, meta, loading, build, modules, tailwindcss, vite
  • Runtime Modules: @nuxtjs/tailwindcss@5.3.0, @pinia/nuxt@0.3.1, @nuxtjs/style-resources@1.2.1, @vueuse/nuxt@8.9.4
  • Build Modules: -

Reproduction

Install nuxt test utils and vitest

yarn add --dev @nuxt/test-utils-edge vitest

Define the nuxt.config.js `//nuxt.config.js import { defineNuxtConfig } from ‘nuxt’

export default defineNuxtConfig({ })`

And create the test file `//test/index.test.js import { $fetch, createTest } from ‘@nuxt/test-utils-edge

const test = createTest({ testDir: ‘./src’, rootDir: ‘.’, server: true, browser: true, configFile: ‘./nuxt.config.js’, dev: true }) // WHERE THE ERROR OCCURS await test.setup()

describe(‘landing page test’, async () => { $fetch(‘http://localhost:31300/’)
})`

Execute test by vitest --dir test --run --reporter verbose --globals --config vitest.config.js

Describe the bug

During the test when the code call the “test.setup”, the error below appears:

FATAL ERROR: v8::FromJust Maybe value is Nothing. 1: 0x10d83c0e5 node::Abort() [/usr/local/bin/node] 2: 0x10d83c268 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]

Debugging the code, the error is being throwed by the code below:

//@nuxt/kit/dist/index.mjs async function loadNuxt(opts) { opts.cwd = opts.cwd || opts.rootDir; opts.overrides = opts.overrides || opts.config || {}; const resolveOpts = { paths: opts.cwd }; opts.overrides.dev = !!opts.dev; const nearestNuxtPkg = await Promise.all([“nuxt3”, “nuxt”, “nuxt-edge”].map((pkg2) => resolvePackageJSON(pkg2, { url: opts.cwd }).catch(() => null))).then(® => r.filter(Boolean).sort((a, b) => b.length - a.length)[0]); if (!nearestNuxtPkg) { throw new Error(Cannot find any nuxt version from ${opts.cwd}); } const pkg = await readPackageJSON(nearestNuxtPkg); const majorVersion = parseInt((pkg.version || “”).split(“.”)[0]); if (majorVersion === 3) { //Can’t load nuxt for some reason const { loadNuxt: loadNuxt3 } = await importModule(pkg._name || pkg.name, resolveOpts); const nuxt2 = await loadNuxt3(opts); return nuxt2; } const { loadNuxt: loadNuxt2 } = await tryImportModule(“nuxt-edge”, resolveOpts) || await importModule(“nuxt”, resolveOpts); const nuxt = await loadNuxt2({ rootDir: opts.cwd, for: opts.dev ? “dev” : “build”, configOverrides: opts.overrides, ready: opts.ready, envConfig: opts.dotenv }); return nuxt; }

Additional context

If an environment to reproduce the issue is required, just send a request to me 😃

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
belomxcommented, Aug 13, 2022
0reactions
danielroecommented, Nov 2, 2022

I’m closing this but if you provide a reproduction I will happily reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@nuxt/test-utils-edge - npm
Start using @nuxt/test-utils-edge in your project by running `npm i @nuxt/test-utils-edge`. There is 1 other project in the npm registry ...
Read more >
Nuxt.js cheat sheet - Christopher Kade
js files and run the yarn test command. Here's a classic (and brief) example of unit testing for a Vue component in a...
Read more >
Introduction to Nuxt Test Utils - Reflect.run
Nuxt Test Utils is a test utility library for Nuxt.js for creating tests for Nuxt projects and modules. It offers several helpful methods...
Read more >
Component testing in Nuxt.js with Jest - LogRocket Blog
Set up a game store application with the Nuxt.js framework and test its components. We'll also explore Vuetify and Vuex.
Read more >
I'm switching from Vuex to Pinia in Vue 3 and my unit tests are ...
I'm using jest along with vue/test-utils. I basically tried just creating the test pinia store, but I can't figure out how to get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found