Skip to content

Releases: johannschopplich/nitro-test-utils

v3.0.0

11 Apr 07:42

Choose a tag to compare

   🚨 Breaking Changes

   🚀 Features

   📖 Migration Guide

In-process request dispatch

v3 stops starting a real HTTP listener for your tests. Instead, the Nitro app is dispatched in-process – each request is handed directly to the app's Web Request handler, the same code path every cloud preset invokes at runtime. No ports, no sockets, no localhost round-trip.

This removes injectServerUrl. Replace it with injectNitroFetch, which returns the raw request dispatcher:

-import { injectServerUrl } from 'nitro-test-utils/e2e'
-const url = injectServerUrl()
+import { injectNitroFetch } from 'nitro-test-utils/e2e'
+const nitroFetch = injectNitroFetch()
+const response = await nitroFetch(new Request('http://nitro.test/api/health'))

Typed $fetchRaw responses

$fetchRaw now inherits route-level typing from Nitro's InternalApi augmentation. Its first generic default changed from T = any to T = unknown, so call sites that dereference data without narrowing will fail to type-check.

The preferred fix is to set up Nitro's type augmentation so $fetchRaw picks up handler return types automatically – see Route-Level Response Types. Where that isn't practical, pass an explicit generic:

-const { data } = await $fetchRaw('/api/users')
-expect(data.id).toBe(1)
+const { data } = await $fetchRaw<{ id: number }>('/api/users')
+expect(data?.id).toBe(1)

Note

The second generic on $fetchRaw previously accepted ofetch's ResponseType ('json', 'text', …). It now represents the request route. This only affects code that passed an explicit second generic – a rarely-used call shape.

    View changes on GitHub

v2.0.3

10 Apr 07:04

Choose a tag to compare

   🐞 Bug Fixes

    View changes on GitHub

v2.0.2

09 Apr 14:39

Choose a tag to compare

   🐞 Bug Fixes

    View changes on GitHub

v2.0.1

09 Apr 14:04

Choose a tag to compare

   🐞 Bug Fixes

    View changes on GitHub

v2.0.0

09 Apr 12:00

Choose a tag to compare

   🚨 Breaking Changes

   📖 Migration Guide

Nitro options as second argument

Nitro v3 ships an official Vite plugin (nitro/vite) that claims the nitro key on Vite's UserConfig for server configuration. Since nitro-test-utils v1 used the same key for test runner configuration, this caused a TypeScript type collision when both packages were used together (#20).

defineConfig now accepts the Nitro test options as a second argument instead of a key on the Vite config. This eliminates the module augmentation entirely – no shared key, no collision, no risk of this happening again.

The update is a one-line change. Move the nitro config object from inside the first argument to the second:

 import { defineConfig } from 'nitro-test-utils/config'

-export default defineConfig({
-  nitro: {
-    global: true,
-  },
-})
+export default defineConfig({}, {
+  global: true,
+})

If you're using custom options, the same pattern applies:

-export default defineConfig({
-  nitro: {
-    global: {
-      rootDir: 'backend',
-      mode: 'production',
-    },
-    rerunOnSourceChanges: false,
-  },
-})
+export default defineConfig({}, {
+  global: {
+    rootDir: 'backend',
+    mode: 'production',
+  },
+  rerunOnSourceChanges: false,
+})
    View changes on GitHub

v1.4.0

09 Apr 08:25

Choose a tag to compare

   🚀 Features

    View changes on GitHub

v1.3.0

25 Mar 14:19

Choose a tag to compare

   🚀 Features

    View changes on GitHub

v1.2.0

23 Mar 15:52

Choose a tag to compare

   🐞 Bug Fixes

    View changes on GitHub

v1.1.0

23 Mar 12:51

Choose a tag to compare

   🚀 Features

   🐞 Bug Fixes

    View changes on GitHub

v1.0.0

14 Mar 10:05

Choose a tag to compare

   🚨 Breaking Changes

   🚀 Features

   🐞 Bug Fixes

   🏎 Performance

    View changes on GitHub