nuxt-monaco-editor icon indicating copy to clipboard operation
nuxt-monaco-editor copied to clipboard

Break test in nuxt environnement

Open ManUtopiK opened this issue 6 months ago • 0 comments

Hi! And thanks a lot for your module.

I noticed that activate this module in a new fresh nuxt app will break test in nuxt environnement. The step to reproduce :

  1. Create a new nuxt app : pnpm dlx nuxi@latest init $NAME
  2. Install test dependencies : pnpm add -D @nuxt/test-utils vitest @vue/test-utils happy-dom // Don't need playwright
  3. Add vitest.config.ts file with :
import { defineVitestConfig } from '@nuxt/test-utils/config'
export default defineVitestConfig()
  1. Add a simple test ./test/basic.test.ts with :
// @vitest-environment nuxt

import { expect, it } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime'

import app from '~/app.vue'

it('should render app', async () => {
  const component = await mountSuspended(app)
  expect(component.html()).toContain('Welcome to Nuxt!')
})
  1. Run the test with npx vitest run

-> It should works.

Now, install nuxt-monaco-editor dependency and add it to modules in nuxt.config.ts file. Re-run the test.

-> Vitest error !

Output :

FAIL  test/basic.test.ts [ test/basic.test.ts ]
Error: Failed to resolve entry for package "monaco-editor". The package may have incorrect main/module/exports specified in its package.json.
 ❯ packageEntryFailure node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46541:15
 ❯ resolvePackageEntry node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46538:3
 ❯ tryNodeResolve node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46354:16
 ❯ ResolveIdContext.resolveId node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46104:19
 ❯ PluginContainer.resolveId node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:48919:17
 ❯ TransformPluginContext.resolve node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:49079:15
 ❯ normalizeUrl node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:63929:26
 ❯ node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:64068:39
 ❯ TransformPluginContext.transform node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:63995:7
 ❯ PluginContainer.transform node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:49000:18
 ❯ loadAndTransform node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:51822:27

ManUtopiK avatar Aug 21 '24 23:08 ManUtopiK