e-chan1007 / nuxt-monaco-editor

Integrate monaco-editor with Nuxt
https://e-chan1007.github.io/nuxt-monaco-editor
MIT License
119 stars 15 forks source link

Break test in nuxt environnement #61

Open ManUtopiK opened 3 months ago

ManUtopiK commented 3 months ago

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()
  4. 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!') })

4. 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 :

```bash
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/vite@5.4.2_@types+node@22.5.0_terser@5.31.6/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46541:15
 ❯ resolvePackageEntry node_modules/.pnpm/vite@5.4.2_@types+node@22.5.0_terser@5.31.6/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46538:3
 ❯ tryNodeResolve node_modules/.pnpm/vite@5.4.2_@types+node@22.5.0_terser@5.31.6/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46354:16
 ❯ ResolveIdContext.resolveId node_modules/.pnpm/vite@5.4.2_@types+node@22.5.0_terser@5.31.6/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:46104:19
 ❯ PluginContainer.resolveId node_modules/.pnpm/vite@5.4.2_@types+node@22.5.0_terser@5.31.6/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:48919:17
 ❯ TransformPluginContext.resolve node_modules/.pnpm/vite@5.4.2_@types+node@22.5.0_terser@5.31.6/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:49079:15
 ❯ normalizeUrl node_modules/.pnpm/vite@5.4.2_@types+node@22.5.0_terser@5.31.6/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:63929:26
 ❯ node_modules/.pnpm/vite@5.4.2_@types+node@22.5.0_terser@5.31.6/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:64068:39
 ❯ TransformPluginContext.transform node_modules/.pnpm/vite@5.4.2_@types+node@22.5.0_terser@5.31.6/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:63995:7
 ❯ PluginContainer.transform node_modules/.pnpm/vite@5.4.2_@types+node@22.5.0_terser@5.31.6/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:49000:18
 ❯ loadAndTransform node_modules/.pnpm/vite@5.4.2_@types+node@22.5.0_terser@5.31.6/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:51822:27