nuxt / test-utils

🧪 Test utilities for Nuxt
http://nuxt.com/docs/getting-started/testing
MIT License
323 stars 84 forks source link

Issue when accessing the nuxt test options from context in startServer function #995

Open trc-mathieu opened 3 weeks ago

trc-mathieu commented 3 weeks ago

If you run yarn run test:e2e in the following reproduction, you'll get this error

    TypeError: Cannot read properties of undefined (reading 'options')

        at startServer (/project/workspace/node_modules/@nuxt/test-utils/dist/shared/test-utils.BHdilg2X.mjs:119:27)
        at Object.setup2 (/project/workspace/node_modules/@nuxt/test-utils/dist/shared/test-utils.B9x0-cXO.mjs:179:7)
        at Object.test$1.extend._nuxtHooks.scope (/project/workspace/node_modules/@nuxt/test-utils/dist/playwright.mjs:22:7)

The nuxt config from the use property is not accessible using the current path ctx.nuxt.options: https://github.com/nuxt/test-utils/blob/df8f6c862f1f8d77097733f13b00f236778c9b56/src/core/server.ts#L62 but works using ctx.options.nuxtConfig instead.

It used to work with ctx.nuxt.options but I recently upgraded to the latest @nuxt/test-utils and I started seing this. The reproduction testifies of this new issue that I have. Maybe I am misusing the use:{nuxt:{} option?