nuxt-monaco-editor
nuxt-monaco-editor copied to clipboard
Break test in nuxt environnement
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 :
- Create a new nuxt app :
pnpm dlx nuxi@latest init $NAME
- Install test dependencies :
pnpm add -D @nuxt/test-utils vitest @vue/test-utils happy-dom
// Don't need playwright - Add
vitest.config.ts
file with :
import { defineVitestConfig } from '@nuxt/test-utils/config'
export default defineVitestConfig()
- 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!')
})
- 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