Skip to content

Releases: nuxt/test-utils

v3.13.0

15 May 16:03
ff98d93
Compare
Choose a tag to compare

compare changes

πŸš€ Enhancements

  • e2e: Improve types for $fetch (b21d9a54)
  • deps: Upgrade execa to v9 (#843)

πŸ”₯ Performance

  • e2e: Don't iterate when cleaning up if nothing registered (#753)

🩹 Fixes

  • e2e: Improve types for fetch and mockLogger (eb40a6a6)
  • e2e: Force string response within startServer (1b182505)
  • e2e: Improve return types for mockLogger (21aa7a2f)
  • runtime: Improve types for renderSuspended and mountSuspended (1636cede)
  • e2e: Revert changes for $fetch inference to unbreak build (dd295d39)
  • vitest: Strongly type vitest environment options (37582c71)
  • module: Correctly filter vite plugins (021824d0)
  • runtime: Preserve setupState return (ab7fd457)
  • playwright: Bump dependency and remove polyfill (#819)
  • runtime: Use effectScope in renderSuspended (#820)
  • e2e: Type $fetch using globalThis instead (b1269edb)
  • Set buildId to nuxt-app for compatibility with nuxt v3.12+ (a00b2c1f)
  • runtime-utils: Use tryUseNuxtApp rather than buildId override (726e0a2d)

🏑 Chore

❀️ Contributors

v3.12.1

15 Apr 14:51
bf553e6
Compare
Choose a tag to compare

compare changes

🩹 Fixes

  • Publish playwright.d.ts (#797)

❀️ Contributors

v3.12.0

16 Mar 21:46
9e33a15
Compare
Choose a tag to compare

compare changes

πŸš€ Enhancements

  • e2e: Add 'route'/'hydration' options for page.goto() (#739)
  • e2e: Add playwright runner (#776)

🩹 Fixes

  • config: Remove nuxt's custom vite logger (eca52f5c)

🏑 Chore

  • Force correct typing for e2e subpath (9fd93a8c)
  • Don't run publish step separately (0078d0bc)

πŸ€– CI

❀️ Contributors

v3.11.0

28 Jan 12:32
5fe47be
Compare
Choose a tag to compare

compare changes

πŸš€ Enhancements

  • vitest-environment: Add support for in-source testing (#651)

🩹 Fixes

  • runtime: Reset modules after nuxt setup runs (#726)

βœ… Tests

  • Add example of mocking vue-router (e293cea1)
  • Add example of mocking nuxt useRoute (fe465193)

❀️ Contributors

v3.10.0

17 Jan 15:52
bc86d23
Compare
Choose a tag to compare

compare changes

πŸš€ Enhancements

  • e2e: Add cucumber test runner (#711)
  • e2e: Support env option for startServer (#640)

🩹 Fixes

  • runtime-utils: Resolve to in RouterLink stub (#687)
  • Mark afterAll and setup hooks as async (#702)
  • module: Always append import when mocking (#701)

🏑 Chore

  • Add required dev deps to app-vitest example (#712)
  • Pin vue/nuxt versions (00674cd0)

βœ… Tests

  • Update config key (25060645)
  • Add example test for nuxt-injected value (#663)
  • Update to actually use $t (#675)

πŸ€– CI

❀️ Contributors

v3.9.0

19 Dec 13:42
681d8d3
Compare
Choose a tag to compare

πŸ‘€ Highlights

v3.9.0 is a significant release of @nuxt/test-utils. Most notably:

  • We've split it out from the core nuxt/nuxt repository for a decoupled release cycle.
  • We've merged in nuxt-vitest and vitest-environment-nuxt into a single repository for both runtime unit testing and e2e/browser testing with Nuxt.
  • We've added documentation on https://nuxt.com/docs/getting-started/testing to get you started.

βœ… Upgrading

... from @nuxt/test-utils

If you were upgrading from @nuxt/test-utils, the only significant change is to update your imports to @nuxt/test-utils/e2e (for clarity).

If you were using the jest runner, this should now be auto-detected and you can remove runner: 'jest' from your test configuration.

... from nuxt-vitest

If you previously used nuxt-vitest, we have now merged it into @nuxt/test-utils, as well as implementing a range of fixes.

πŸ‘‰ Here are the required steps.
  1. Uninstall nuxt-vitest

    npm remove nuxt-vitest
  2. Update your vitest versions to v1, and update @nuxt/test-utils and vitest-environment-nuxt to the latest versions:

      "devDependencies": {
    -   "@nuxt/test-utils": "^3.8.1",
    +   "@nuxt/test-utils": "^3.9.0",
    -   "@vitest/coverage-v8": "0.33.0",
    +   "@vitest/coverage-v8": "^1.0.4",
        "@vue/test-utils": "^2.4.3",
    -   "nuxt-vitest": "^0.11.5",
    -   "vitest": "^0.33.0",
    +   "vitest": "^1.0.4",
    +   "vitest-environment-nuxt": "^1.0.0"
      },
  3. Update your nuxt.config if you have added the nuxt-vitest module to it, and update the configuration from vitest to testUtils:

      export default defineNuxtConfig({
       modules: [
    -    'nuxt-vitest'
    +    '@nuxt/test-utils/module'
       ],
    -  vitest: {}
    +  testUtils: {}
      })
  4. Update any imports from nuxt-vitest and vitest-environment-nuxt and @nuxt/test-utils:

    -  import { mountSuspended } from 'nuxt-vitest/utils' // or 'vitest-environment-nuxt/utils'
    +  import { mountSuspended } from '@nuxt/test-utils/runtime'
    
    -  import { defineVitestConfig } from 'vitest-environment-nuxt/config' // or 'nuxt-vitest/config'
    +  import { defineVitestConfig } from '@nuxt/test-utils/config'
    
    -  import { setup, $fetch } from '@nuxt/test-utils'
    +  import { setup, $fetch } from '@nuxt/test-utils/e2e'
  5. Ensure vitest is running in a module context (either by checking you have type: 'module' set in your package.json, or by renaming your vitest.config file to vitest.config.mts or vitest.config.mjs.

If you encounter any problems with this upgrade path, please let us know by raising an issue. πŸ™

πŸ‘‰ Changelog

compare changes

πŸš€ Enhancements

  • Add nuxt-vitest re-exports (#230)
  • Add nuxt-vitest and vitest-environment-nuxt code and tests (f4ae58ac)
  • Use internal implementation of nuxt-vitest (#235)
  • e2e: Auto-detect jest runner (ae37b0ee)
  • ⚠️ Read .env.test + allow overriding with nuxt.dotenv (#655)

🩹 Fixes

  • Add @nuxt/test-utils-nightly to deps to inline (0caf44d0)
  • Use implied .d.mts types (d9694f21)
  • Add setupState type to mountSuspended return type (#400)
  • Add runtime fixture to workspace and address regressions (#240)
  • Opt-in to future vitest option (#247)
  • Use vite-ignore for playwright dynamic import (c1ac4a08)
  • Do not set process.browser globally (#250)
  • Support transpiling nuxt nightly releases (c63f69c8)
  • Rewrite mock plugin for compat with vite 5/rollup 4 (d0ba5af3)
  • Do not skip transforms on test files (3bbcc1ea)
  • Add @vitest/ui to peer deps (7f4f6053)
  • Use buildDir option (#596)
  • ⚠️ Load nuxt app within setupFiles (#260)
  • Teardown build directories after tests (#597)
  • Import useRouter explicitly in entry (129d8335)
  • Return absolute path for stub entry (180bb306)
  • Don't return absolute path in dev mode (f47dd9a3)
  • Clone overrides (df84d0c1)
  • Skip vite-plugin-vue-inspector:post plugin (8a6a0523)
  • Clean up wrappers when calling renderSuspended (5b189115)
  • Exclude vite-plugin-checker from runtime vitest config (053a5dff)
  • Resolve devtools url after vitest config is resolved (1206db79)
  • Remove module override of app.rootId (e662c1f0)
  • Remove rootId environment option (dead5e3d)
  • Add back rootId environment option" (827180ec)
  • runtime-utils: Don't stub helpers when shallow (#632)
  • Avoid enumerating keys on render context (43b2724b)
  • Support typescript entry file (c5806009)
  • vitest-environment: Normalise setupFiles before merge (#653)
  • module: Close nuxt before shutting down (17cf9435)
  • runtime: Do not assign readonly setup state (8d799275)
  • runtime: Implement setProps (522f8bf5)
  • vitest-environment: Handle different entry format (5c07bb48)
  • runtime: Import reactive and unref (d68cdae9)

πŸ’… Refactors

  • Move to monorepo (#31)
  • Split core utils to core/ (f144cb40)
  • Clean up internal code imports (#245)
  • Use defu rather than mergeConfig from vite (#246)
  • Further split vitest from vite config (ef58e4cb)
  • Split out mock transform plugin w/ tests (a37fa408)
  • Remove rollup implementation of transform plugin (71345967)
  • module: Rename config key to testUtils (c2b09732)

πŸ“– Documentation

  • playground: Demo usage of co-exists unit and nuxt testing (#6)
  • Add JSDoc comments (#205)
  • Add documentation for mountSuspended (#227)
  • Add basic README and missing LICENCE (51eb9de2)
  • Remove links to nuxt-vitest (254605df)
  • Update links to nuxt docs on testing (2e619a89)

πŸ“¦ Build

  • Fix build issues and correct dependencies (3e2f8b29)
  • Move runtime-utils.mjs -> runtime-utils/index.mjs (#634)
  • ⚠️ Use /runtime subpath export (de9a2a81)
  • Prefer /e2e subpath export (88952fb0)

βœ… Tests

  • Update playground to 0.4.5 devtools (7d4a6b28)
  • Add useHead to fixture (6d4bb420)
  • Add type tests (9de62b6e)
  • Await 2 ticks after navigation for route to update (cb6c1e3a)
  • Correct test assertion (c644bdb3)
  • Avoid depending on specific number of ticks (e98d71ea)
  • Update test to use server rather than live api (7df6be28)
  • Add a few more basic examples for e2e tests (490753c4)
  • Add jest example/test (#224)
  • Add type test (#241)
  • Make indexeddb plugin client-only ([047...
Read more