@nuxt/test-utils
Version:
Test utilities for Nuxt
68 lines (65 loc) • 2.13 kB
text/typescript
import { NuxtConfig, Nuxt } from '@nuxt/schema';
import { InlineConfig } from 'vitest/node';
import { TestProjectInlineConfiguration } from 'vitest/config';
import { DotenvOptions } from 'c12';
import { UserConfig, UserConfigFnPromise } from 'vite';
interface GetVitestConfigOptions {
nuxt: Nuxt;
viteConfig: UserConfig;
}
interface LoadNuxtOptions {
dotenv?: Partial<DotenvOptions>;
overrides?: Partial<NuxtConfig>;
}
declare function getVitestConfigFromNuxt(options?: GetVitestConfigOptions, loadNuxtOptions?: LoadNuxtOptions): Promise<UserConfig & {
test: InlineConfig;
}>;
declare function defineVitestProject(config: TestProjectInlineConfiguration): Promise<TestProjectInlineConfiguration>;
declare function defineVitestConfig(config?: UserConfig & {
test?: InlineConfig;
}): UserConfigFnPromise;
interface NuxtEnvironmentOptions {
rootDir?: string;
/**
* The starting URL for your Nuxt window environment
* @default 'http://localhost:3000'
*/
url?: string;
/**
* You can define how environment options are read when loading the Nuxt configuration.
*/
dotenv?: Partial<DotenvOptions>;
/**
* Configuration that will override the values in your `nuxt.config` file.
*/
overrides?: NuxtConfig;
/**
* The id of the root div to which the app should be mounted. You should also set `app.rootId` to the same value.
* @default 'nuxt-test'
*/
rootId?: string;
/**
* The name of the DOM environment to use.
*
* It also needs to be installed as a dev dependency in your project.
* @default 'happy-dom'
*/
domEnvironment?: 'happy-dom' | 'jsdom';
h3Version?: 1 | 2;
mock?: {
intersectionObserver?: boolean;
indexedDb?: boolean;
};
}
declare module 'vitest/node' {
interface EnvironmentOptions {
nuxt?: NuxtEnvironmentOptions;
}
}
declare module 'vitest' {
interface EnvironmentOptions {
nuxt?: NuxtEnvironmentOptions;
}
}
export { defineVitestConfig, defineVitestProject, getVitestConfigFromNuxt };
export type { NuxtEnvironmentOptions };