Skip to content

@i18n-micro/test-utils ​

60 exports across 2 entry points. Generated from the API snapshot that pnpm run api:surface checks against the TypeScript sources.

@i18n-micro/test-utils ​

ts
import { /* … */ } from '@i18n-micro/test-utils'
ExportKindSignature
_tfunction(route: unknown) => (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => import("@i18n-micro/types").Translation
_tsfunction(route: unknown) => (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => string
createFakeI18nfunction(options?: CreateFakeI18nOptions) => { $i18nStrategy: { getStrategy: () => import("./context").TestStrategy; getDefaultLocale: () => string; getLocales: () => import("./context").Locale[]; getLocalizedRouteNamePrefix: () => string; getGlobalLocaleRoutes: () => undefined; getRouteLocales: () => undefined; getRoutesLocaleLinks: () => undefined; getNoPrefixRedirect: () => undefined; getRouteBaseName: () => null; formatPathForResolve: (path: string) => string; setRouter: () => void; getCanonicalPath: () => null; getRedirect: () => null; shouldReturn404: () => null; getClientRedirect: () => null; resolveLocaleFromPath(path: string): string | null; getLocaleFromPath(path: string): string | null; getCurrentLocale: () => string; getPluginRouteName: () => string; getCurrentLocaleName: () => string | null; localeRoute(targetLocale: string, routeOrPath: unknown): { path: string; fullPath: string; }; switchLocaleRoute(_fromLocale: string, toLocale: string, route?: unknown): { path: string; fullPath: string; }; }; $getI18nConfig: () => { locales: import("./context").Locale[]; defaultLocale: string | undefined; strategy: import("./context").TestStrategy; }; $getLocale: (_route?: unknown) => string; $setLocale: (val: string) => void; $getLocaleName: () => string | null; $setLocaleName: (val: string | null) => void; $getLocales: () => import("./context").Locale[]; $setLocales: (val: import("./context").Locale[]) => void; $defaultLocale: () => string | undefined; $setDefaultLocale: (val: string | undefined) => void; $getRouteName: (_route?: unknown, _locale?: string) => string; $settRouteName: (val: string) => void; $setRouteName: (val: string) => void; $t: (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => import("@i18n-micro/types").Translation; $_t: (route: unknown) => (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => import("@i18n-micro/types").Translation; $ts: (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => string; $_ts: (route: unknown) => (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => string; $tc: (key: import("@i18n-micro/types").TranslationKey, params: number | import("@i18n-micro/types").Params, defaultValue?: string) => string; $tn: (value: number, options?: Intl.NumberFormatOptions) => string; $td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; $tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; $has: (key: import("@i18n-micro/types").TranslationKey) => boolean; $resolveTranslations: () => Record<string, unknown>; $setTranslation: (key: import("@i18n-micro/types").TranslationKey, value: unknown) => void; $mergeTranslations: (newTranslations: import("@i18n-micro/types").Translations) => void; $switchLocaleRoute: (loc: string) => { path: string; name: string; }; $switchLocalePath: (loc: string) => string; $switchLocale: (val: string) => void; $switchRoute: (route: unknown, toLocale?: string) => void; $localeRoute: (to: unknown, loc?: string) => { name?: string | symbol | undefined; path: string; }; $localePath: (to: unknown, loc?: string) => string; $setI18nRouteParams: (value: unknown) => unknown; $loadPageTranslations: (loc: string, page: string, translations: import("@i18n-micro/types").Translations) => Promise<void>; $setMissingHandler: (handler: import("@i18n-micro/types").MissingHandler | null) => void; $setTranslationsFromJson: (loc: string, translations: Record<string, unknown>) => Promise<void>; helper: { hasCache(locale: string, page: string): boolean; getCache(locale: string, routeName: string): import("@i18n-micro/types").Translations | undefined; setCache(_locale: string, _routeName: string, _cache: Map<string, unknown>): void; hasTranslation(locale: string, key: string): boolean; hasPageTranslation(locale: string, routeName: string): boolean; getTranslation<T = unknown>(locale: string, routeName: string, key: string): T | null; loadTranslations(locale: string, data: import("@i18n-micro/types").Translations, routeName?: string): void; setTranslations(locale: string, data: import("@i18n-micro/types").Translations, routeName?: string): void; loadPageTranslations(locale: string, routeName: string, data: import("@i18n-micro/types").Translations): void; mergeTranslation(locale: string, routeName: string, newTranslations: import("@i18n-micro/types").Translations, _force?: boolean): void; clearCache(): void; }; }
CreateFakeI18nOptionsinterface10 members
createI18nTestContextfunction(options?: CreateI18nTestContextOptions) => I18nTestContext
CreateI18nTestContextOptionsinterface9 members
createIsolatedFakeI18nfunction(options?: CreateFakeI18nOptions) => IsolatedFakeI18n
defaultLocaleconst() => string | undefined
getI18nConfigconst() => { locales: import("./context").Locale[]; defaultLocale: string | undefined; strategy: import("./context").TestStrategy; }
getLocaleconst(_route?: unknown) => string
getLocaleNameconst() => string | null
getLocalesconst() => import("./context").Locale[]
getRouteNameconst(_route?: unknown, _locale?: string | undefined) => string
Gettertype(key: TranslationKey, params?: Record<string, string | number | boolean>, defaultValue?: string) => unknown
hasconst(key: string) => boolean
i18nStrategyconst{ getStrategy: () => import("./context").TestStrategy; getDefaultLocale: () => string; getLocales: () => import("./context").Locale[]; getLocalizedRouteNamePrefix: () => string; getGlobalLocaleRoutes: () => undefined; getRouteLocales: () => undefined; getRoutesLocaleLinks: () => undefined; getNoPrefixRedirect: () => undefined; getRouteBaseName: () => null; formatPathForResolve: (path: string) => string; setRouter: () => void; getCanonicalPath: () => null; getRedirect: () => null; shouldReturn404: () => null; getClientRedirect: () => null; resolveLocaleFromPath(path: string): string | null; getLocaleFromPath(path: string): string | null; getCurrentLocale: () => string; getPluginRouteName: () => string; getCurrentLocaleName: () => string | null; localeRoute(targetLocale: string, routeOrPath: unknown): { path: string; fullPath: string; }; switchLocaleRoute(_fromLocale: string, toLocale: string, route?: unknown): { path: string; fullPath: string; }; }
I18nTestContextclass50 members
i18nUtilsconst{ t: (key: string, params?: import("@i18n-micro/types").Params | undefined, defaultValue?: string | null | undefined) => unknown; tc: (key: string, params: number | import("@i18n-micro/types").Params, defaultValue?: string | undefined) => string; ts: (key: string, params?: import("@i18n-micro/types").Params | undefined, defaultValue?: string | null | undefined) => string; tn: (value: number, options?: Intl.NumberFormatOptions | undefined) => string; td: (value: string | number | Date, options?: Intl.DateTimeFormatOptions | undefined) => string; tdr: (value: string | number | Date, options?: Intl.RelativeTimeFormatOptions | undefined) => string; has: (key: string) => boolean; resetI18n: (options?: ResetI18nOptions) => void; createFakeI18n: (options?: CreateFakeI18nOptions) => { $i18nStrategy: { getStrategy: () => import("./context").TestStrategy; getDefaultLocale: () => string; getLocales: () => import("./context").Locale[]; getLocalizedRouteNamePrefix: () => string; getGlobalLocaleRoutes: () => undefined; getRouteLocales: () => undefined; getRoutesLocaleLinks: () => undefined; getNoPrefixRedirect: () => undefined; getRouteBaseName: () => null; formatPathForResolve: (path: string) => string; setRouter: () => void; getCanonicalPath: () => null; getRedirect: () => null; shouldReturn404: () => null; getClientRedirect: () => null; resolveLocaleFromPath(path: string): string | null; getLocaleFromPath(path: string): string | null; getCurrentLocale: () => string; getPluginRouteName: () => string; getCurrentLocaleName: () => string | null; localeRoute(targetLocale: string, routeOrPath: unknown): { path: string; fullPath: string; }; switchLocaleRoute(_fromLocale: string, toLocale: string, route?: unknown): { path: string; fullPath: string; }; }; $getI18nConfig: () => { locales: import("./context").Locale[]; defaultLocale: string | undefined; strategy: import("./context").TestStrategy; }; $getLocale: (_route?: unknown) => string; $setLocale: (val: string) => void; $getLocaleName: () => string | null; $setLocaleName: (val: string | null) => void; $getLocales: () => import("./context").Locale[]; $setLocales: (val: import("./context").Locale[]) => void; $defaultLocale: () => string | undefined; $setDefaultLocale: (val: string | undefined) => void; $getRouteName: (_route?: unknown, _locale?: string) => string; $settRouteName: (val: string) => void; $setRouteName: (val: string) => void; $t: (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => import("@i18n-micro/types").Translation; $_t: (route: unknown) => (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => import("@i18n-micro/types").Translation; $ts: (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => string; $_ts: (route: unknown) => (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => string; $tc: (key: import("@i18n-micro/types").TranslationKey, params: number | import("@i18n-micro/types").Params, defaultValue?: string) => string; $tn: (value: number, options?: Intl.NumberFormatOptions) => string; $td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; $tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; $has: (key: import("@i18n-micro/types").TranslationKey) => boolean; $resolveTranslations: () => Record<string, unknown>; $setTranslation: (key: import("@i18n-micro/types").TranslationKey, value: unknown) => void; $mergeTranslations: (newTranslations: import("@i18n-micro/types").Translations) => void; $switchLocaleRoute: (loc: string) => { path: string; name: string; }; $switchLocalePath: (loc: string) => string; $switchLocale: (val: string) => void; $switchRoute: (route: unknown, toLocale?: string) => void; $localeRoute: (to: unknown, loc?: string) => { name?: string | symbol | undefined; path: string; }; $localePath: (to: unknown, loc?: string) => string; $setI18nRouteParams: (value: unknown) => unknown; $loadPageTranslations: (loc: string, page: string, translations: import("@i18n-micro/types").Translations) => Promise<void>; $setMissingHandler: (handler: import("@i18n-micro/types").MissingHandler | null) => void; $setTranslationsFromJson: (loc: string, translations: Record<string, unknown>) => Promise<void>; helper: { hasCache(locale: string, page: string): boolean; getCache(locale: string, routeName: string): import("@i18n-micro/types").Translations | undefined; setCache(_locale: string, _routeName: string, _cache: Map<string, unknown>): void; hasTranslation(locale: string, key: string): boolean; hasPageTranslation(locale: string, routeName: string): boolean; getTranslation<T = unknown>(locale: string, routeName: string, key: string): T | null; loadTranslations(locale: string, data: import("@i18n-micro/types").Translations, routeName?: string): void; setTranslations(locale: string, data: import("@i18n-micro/types").Translations, routeName?: string): void; loadPageTranslations(locale: string, routeName: string, data: import("@i18n-micro/types").Translations): void; mergeTranslation(locale: string, routeName: string, newTranslations: import("@i18n-micro/types").Translations, _force?: boolean): void; clearCache(): void; }; }; createIsolatedFakeI18n: (options?: CreateFakeI18nOptions) => IsolatedFakeI18n; setupNuxtI18nMock: (options?: SetupNuxtI18nMockOptions) => NuxtI18nMockHarness; createI18nTestContext: (options?: import("./context").CreateI18nTestContextOptions) => I18nTestContext; setTranslationsFromJson: (loc: string, translations: Record<string, unknown>) => Promise<void>; loadPageTranslations: (loc: string, page: string, translations: import("@i18n-micro/types").Translations) => Promise<void>; setMissingHandler: (handler: import("@i18n-micro/types").MissingHandler | null) => void; getI18nConfig: () => { locales: import("./context").Locale[]; defaultLocale: string | undefined; strategy: import("./context").TestStrategy; }; i18nStrategy: { getStrategy: () => import("./context").TestStrategy; getDefaultLocale: () => string; getLocales: () => import("./context").Locale[]; getLocalizedRouteNamePrefix: () => string; getGlobalLocaleRoutes: () => undefined; getRouteLocales: () => undefined; getRoutesLocaleLinks: () => undefined; getNoPrefixRedirect: () => undefined; getRouteBaseName: () => null; formatPathForResolve: (path: string) => string; setRouter: () => void; getCanonicalPath: () => null; getRedirect: () => null; shouldReturn404: () => null; getClientRedirect: () => null; resolveLocaleFromPath(path: string): string | null; getLocaleFromPath(path: string): string | null; getCurrentLocale: () => string; getPluginRouteName: () => string; getCurrentLocaleName: () => string | null; localeRoute(targetLocale: string, routeOrPath: unknown): { path: string; fullPath: string; }; switchLocaleRoute(_fromLocale: string, toLocale: string, route?: unknown): { path: string; fullPath: string; }; }; getLocale: (_route?: unknown) => string; setLocale: (val: string) => void; getLocaleName: () => string | null; setLocaleName: (val: string | null) => void; getLocales: () => import("./context").Locale[]; setLocales: (val: import("./context").Locale[]) => void; defaultLocale: () => string | undefined; setDefaultLocale: (val: string | undefined) => void; getRouteName: (_route?: unknown, _locale?: string | undefined) => string; settRouteName: (val: string) => void; setRouteName: (val: string) => void; _t: (route: unknown) => (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => import("@i18n-micro/types").Translation; _ts: (route: unknown) => (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => string; mergeTranslations: (newTranslations: import("@i18n-micro/types").Translations) => void; resolveTranslations: () => Record<string, unknown>; setTranslation: (key: string, value: unknown) => void; switchLocaleRoute: (loc: string) => { path: string; name: string; }; switchLocalePath: (loc: string) => string; switchLocale: (val: string) => void; switchRoute: (route: unknown, toLocale?: string | undefined) => void; localeRoute: (to: unknown, loc?: string | undefined) => { name?: string | symbol | undefined; path: string; }; localePath: (to: unknown, loc?: string | undefined) => string; setI18nRouteParams: (value: unknown) => unknown; }
IsolatedFakeI18ninterface4 members
loadPageTranslationsfunction(loc: string, page: string, translations: import("@i18n-micro/types").Translations) => Promise<void>
Localeinterface7 members
LocaleCodetypestring
localePathconst(to: unknown, loc?: string | undefined) => string
localeRouteconst(to: unknown, loc?: string | undefined) => { name?: string | symbol | undefined; path: string; }
mergeTranslationsconst(newTranslations: import("@i18n-micro/types").Translations) => void
NuxtI18nMockHarnessinterface5 members
resetI18nfunction(options?: ResetI18nOptions) => void
ResetI18nOptionsinterface8 members
resolveTranslationsconst() => Record<string, unknown>
setDefaultLocaleconst(val: string | undefined) => void
setI18nRouteParamsconst(value: unknown) => unknown
setLocaleconst(val: string) => void
setLocaleNameconst(val: string | null) => void
setLocalesconst(val: import("./context").Locale[]) => void
setMissingHandlerconst(handler: import("@i18n-micro/types").MissingHandler | null) => void
setRouteNameconst(val: string) => void
setTranslationconst(key: string, value: unknown) => void
setTranslationsFromJsonfunction(loc: string, translations: Record<string, unknown>) => Promise<void>
settRouteNameconst(val: string) => void
setupNuxtI18nMockfunction(options?: SetupNuxtI18nMockOptions) => NuxtI18nMockHarness
SetupNuxtI18nMockOptionsinterface12 members
SpyFntype<T>(fn: T) => T
switchLocaleconst(val: string) => void
switchLocalePathconst(loc: string) => string
switchLocaleRouteconst(loc: string) => { path: string; name: string; }
switchRouteconst(route: unknown, toLocale?: string | undefined) => void
tfunction(key: string, params?: import("@i18n-micro/types").Params | undefined, defaultValue?: string | null | undefined) => unknown
tcfunction(key: string, params: number | import("@i18n-micro/types").Params, defaultValue?: string | undefined) => string
tdconst(value: string | number | Date, options?: Intl.DateTimeFormatOptions | undefined) => string
tdrconst(value: string | number | Date, options?: Intl.RelativeTimeFormatOptions | undefined) => string
TestStrategytype'prefix' | 'prefix_except_default' | 'prefix_and_default' | 'no_prefix'
tnconst(value: number, options?: Intl.NumberFormatOptions | undefined) => string
tsfunction(key: string, params?: import("@i18n-micro/types").Params | undefined, defaultValue?: string | null | undefined) => string
CreateFakeI18nOptions — 10 members
MemberType
defaultLocale?string | undefined
isolated?boolean | undefined
locale?string | undefined
localeName?string | null | undefined
locales?Locale[] | undefined
messages?Record<string, Record<string, unknown>> | undefined
routeName?string | undefined
spy?SpyFn | undefined
strategy?TestStrategy | undefined
translations?Record<string, unknown> | undefined
CreateI18nTestContextOptions — 9 members
MemberType
defaultLocale?string | undefined
isolated?boolean | undefined
locale?string | undefined
localeName?string | null | undefined
locales?Locale[] | undefined
messages?Record<string, Record<string, unknown>> | undefined
routeName?string | undefined
strategy?TestStrategy | undefined
translations?Record<string, unknown> | undefined
I18nTestContext — 50 members
MemberType
_t(route: unknown) => (key: TranslationKey, params?: Params, defaultValue?: string | null) => Translation
_ts(route: unknown) => (key: TranslationKey, params?: Params, defaultValue?: string | null) => string
applyResetprivate (options: ResetI18nOptions) => void
createFake(spy?: SpyFn) => { $i18nStrategy: { getStrategy: () => TestStrategy; getDefaultLocale: () => string; getLocales: () => Locale[]; getLocalizedRouteNamePrefix: () => string; getGlobalLocaleRoutes: () => undefined; getRouteLocales: () => undefined; getRoutesLocaleLinks: () => undefined; getNoPrefixRedirect: () => undefined; getRouteBaseName: () => null; formatPathForResolve: (path: string) => string; setRouter: () => void; getCanonicalPath: () => null; getRedirect: () => null; shouldReturn404: () => null; getClientRedirect: () => null; resolveLocaleFromPath(path: string): string | null; getLocaleFromPath(path: string): string | null; getCurrentLocale: () => string; getPluginRouteName: () => string; getCurrentLocaleName: () => string | null; localeRoute(targetLocale: string, routeOrPath: unknown): { path: string; fullPath: string; }; switchLocaleRoute(_fromLocale: string, toLocale: string, route?: unknown): { path: string; fullPath: string; }; }; $getI18nConfig: () => { locales: Locale[]; defaultLocale: string | undefined; strategy: TestStrategy; }; $getLocale: (_route?: unknown) => string; $setLocale: (val: string) => void; $getLocaleName: () => string | null; $setLocaleName: (val: string | null) => void; $getLocales: () => Locale[]; $setLocales: (val: Locale[]) => void; $defaultLocale: () => string | undefined; $setDefaultLocale: (val: string | undefined) => void; $getRouteName: (_route?: unknown, _locale?: string) => string; $settRouteName: (val: string) => void; $setRouteName: (val: string) => void; $t: (key: TranslationKey, params?: Params, defaultValue?: string | null) => Translation; $_t: (route: unknown) => (key: TranslationKey, params?: Params, defaultValue?: string | null) => Translation; $ts: (key: TranslationKey, params?: Params, defaultValue?: string | null) => string; $_ts: (route: unknown) => (key: TranslationKey, params?: Params, defaultValue?: string | null) => string; $tc: (key: TranslationKey, params: number | Params, defaultValue?: string) => string; $tn: (value: number, options?: Intl.NumberFormatOptions) => string; $td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; $tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; $has: (key: TranslationKey) => boolean; $resolveTranslations: () => Record<string, unknown>; $setTranslation: (key: TranslationKey, value: unknown) => void; $mergeTranslations: (newTranslations: Translations) => void; $switchLocaleRoute: (loc: string) => { path: string; name: string; }; $switchLocalePath: (loc: string) => string; $switchLocale: (val: string) => void; $switchRoute: (route: unknown, toLocale?: string) => void; $localeRoute: (to: unknown, loc?: string) => { name?: string | symbol | undefined; path: string; }; $localePath: (to: unknown, loc?: string) => string; $setI18nRouteParams: (value: unknown) => unknown; $loadPageTranslations: (loc: string, page: string, translations: Translations) => Promise<void>; $setMissingHandler: (handler: MissingHandler | null) => void; $setTranslationsFromJson: (loc: string, translations: Record<string, unknown>) => Promise<void>; helper: { hasCache(locale: string, page: string): boolean; getCache(locale: string, routeName: string): Translations | undefined; setCache(_locale: string, _routeName: string, _cache: Map<string, unknown>): void; hasTranslation(locale: string, key: string): boolean; hasPageTranslation(locale: string, routeName: string): boolean; getTranslation<T = unknown>(locale: string, routeName: string, key: string): T | null; loadTranslations(locale: string, data: Translations, routeName?: string): void; setTranslations(locale: string, data: Translations, routeName?: string): void; loadPageTranslations(locale: string, routeName: string, data: Translations): void; mergeTranslation(locale: string, routeName: string, newTranslations: Translations, _force?: boolean): void; clearCache(): void; }; }
defaultLocale() => string | undefined
defLocaleprivate string | undefined
getI18nConfig() => { locales: Locale[]; defaultLocale: string | undefined; strategy: TestStrategy; }
getLocale(_route?: unknown) => string
getLocaleName() => string | null
getLocales() => Locale[]
getRouteName(_route?: unknown, _locale?: string) => string
has(key: TranslationKey) => boolean
helper{ hasCache(locale: string, page: string): boolean; getCache(locale: string, routeName: string): Translations | undefined; setCache(_locale: string, _routeName: string, _cache: Map<string, unknown>): void; hasTranslation(locale: string, key: string): boolean; hasPageTranslation(locale: string, routeName: string): boolean; getTranslation<T = unknown>(locale: string, routeName: string, key: string): T | null; loadTranslations(locale: string, data: Translations, routeName?: string): void; setTranslations(locale: string, data: Translations, routeName?: string): void; loadPageTranslations(locale: string, routeName: string, data: Translations): void; mergeTranslation(locale: string, routeName: string, newTranslations: Translations, _force?: boolean): void; clearCache(): void; }
i18nRouteParamsprivate unknown
i18nStrategy{ getStrategy: () => TestStrategy; getDefaultLocale: () => string; getLocales: () => Locale[]; getLocalizedRouteNamePrefix: () => string; getGlobalLocaleRoutes: () => undefined; getRouteLocales: () => undefined; getRoutesLocaleLinks: () => undefined; getNoPrefixRedirect: () => undefined; getRouteBaseName: () => null; formatPathForResolve: (path: string) => string; setRouter: () => void; getCanonicalPath: () => null; getRedirect: () => null; shouldReturn404: () => null; getClientRedirect: () => null; resolveLocaleFromPath(path: string): string | null; getLocaleFromPath(path: string): string | null; getCurrentLocale: () => string; getPluginRouteName: () => string; getCurrentLocaleName: () => string | null; localeRoute(targetLocale: string, routeOrPath: unknown): { path: string; fullPath: string; }; switchLocaleRoute(_fromLocale: string, toLocale: string, route?: unknown): { path: string; fullPath: string; }; }
initialprivate Required<Pick<ResetI18nOptions, "locale" | "locales" | "routeName" | "localeName" | "strategy">> & Pick<ResetI18nOptions, "defaultLocale" | "translations" | "messages">
loadPageTranslations(loc: string, page: string, translations: Translations) => Promise<void>
localeprivate string
localeNameprivate string | null
localePath(to: unknown, loc?: string) => string
localeRoute(to: unknown, loc?: string) => { name?: string | symbol | undefined; path: string; }
localesprivate Locale[]
mergeTranslations(newTranslations: Translations) => void
missingHandlerprivate MissingHandler | null
new(options?: CreateI18nTestContextOptions): I18nTestContext
pagePathstring
reset(options?: ResetI18nOptions & { reseed?: boolean; }) => void
resolveTranslations() => Record<string, unknown>
routeNameprivate string
setDefaultLocale(val: string | undefined) => void
setI18nRouteParams(value: unknown) => unknown
setLocale(val: string) => void
setLocaleName(val: string | null) => void
setLocales(val: Locale[]) => void
setMissingHandler(handler: MissingHandler | null) => void
setRouteName(val: string) => void
setTranslation(key: TranslationKey, value: unknown) => void
setTranslationsFromJson(loc: string, translations: Record<string, unknown>) => Promise<void>
settRouteName(val: string) => void
strategyTestStrategy
switchLocale(val: string) => void
switchLocalePath(loc: string) => string
switchLocaleRoute(loc: string) => { path: string; name: string; }
switchRoute(route: unknown, toLocale?: string) => void
t(key: TranslationKey, params?: Params, defaultValue?: string | null) => Translation
tc(key: TranslationKey, params: number | Params, defaultValue?: string) => string
td(value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string
tdr(value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string
tn(value: number, options?: Intl.NumberFormatOptions) => string
ts(key: TranslationKey, params?: Params, defaultValue?: string | null) => string
IsolatedFakeI18n — 4 members
MemberType
contextI18nTestContext
i18n{ $i18nStrategy: { getStrategy: () => import("./context").TestStrategy; getDefaultLocale: () => string; getLocales: () => import("./context").Locale[]; getLocalizedRouteNamePrefix: () => string; getGlobalLocaleRoutes: () => undefined; getRouteLocales: () => undefined; getRoutesLocaleLinks: () => undefined; getNoPrefixRedirect: () => undefined; getRouteBaseName: () => null; formatPathForResolve: (path: string) => string; setRouter: () => void; getCanonicalPath: () => null; getRedirect: () => null; shouldReturn404: () => null; getClientRedirect: () => null; resolveLocaleFromPath(path: string): string | null; getLocaleFromPath(path: string): string | null; getCurrentLocale: () => string; getPluginRouteName: () => string; getCurrentLocaleName: () => string | null; localeRoute(targetLocale: string, routeOrPath: unknown): { path: string; fullPath: string; }; switchLocaleRoute(_fromLocale: string, toLocale: string, route?: unknown): { path: string; fullPath: string; }; }; $getI18nConfig: () => { locales: import("./context").Locale[]; defaultLocale: string | undefined; strategy: import("./context").TestStrategy; }; $getLocale: (_route?: unknown) => string; $setLocale: (val: string) => void; $getLocaleName: () => string | null; $setLocaleName: (val: string | null) => void; $getLocales: () => import("./context").Locale[]; $setLocales: (val: import("./context").Locale[]) => void; $defaultLocale: () => string | undefined; $setDefaultLocale: (val: string | undefined) => void; $getRouteName: (_route?: unknown, _locale?: string) => string; $settRouteName: (val: string) => void; $setRouteName: (val: string) => void; $t: (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => import("@i18n-micro/types").Translation; $_t: (route: unknown) => (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => import("@i18n-micro/types").Translation; $ts: (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => string; $_ts: (route: unknown) => (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => string; $tc: (key: import("@i18n-micro/types").TranslationKey, params: number | import("@i18n-micro/types").Params, defaultValue?: string) => string; $tn: (value: number, options?: Intl.NumberFormatOptions) => string; $td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; $tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; $has: (key: import("@i18n-micro/types").TranslationKey) => boolean; $resolveTranslations: () => Record<string, unknown>; $setTranslation: (key: import("@i18n-micro/types").TranslationKey, value: unknown) => void; $mergeTranslations: (newTranslations: import("@i18n-micro/types").Translations) => void; $switchLocaleRoute: (loc: string) => { path: string; name: string; }; $switchLocalePath: (loc: string) => string; $switchLocale: (val: string) => void; $switchRoute: (route: unknown, toLocale?: string) => void; $localeRoute: (to: unknown, loc?: string) => { name?: string | symbol | undefined; path: string; }; $localePath: (to: unknown, loc?: string) => string; $setI18nRouteParams: (value: unknown) => unknown; $loadPageTranslations: (loc: string, page: string, translations: import("@i18n-micro/types").Translations) => Promise<void>; $setMissingHandler: (handler: import("@i18n-micro/types").MissingHandler | null) => void; $setTranslationsFromJson: (loc: string, translations: Record<string, unknown>) => Promise<void>; helper: { hasCache(locale: string, page: string): boolean; getCache(locale: string, routeName: string): import("@i18n-micro/types").Translations | undefined; setCache(_locale: string, _routeName: string, _cache: Map<string, unknown>): void; hasTranslation(locale: string, key: string): boolean; hasPageTranslation(locale: string, routeName: string): boolean; getTranslation<T = unknown>(locale: string, routeName: string, key: string): T | null; loadTranslations(locale: string, data: import("@i18n-micro/types").Translations, routeName?: string): void; setTranslations(locale: string, data: import("@i18n-micro/types").Translations, routeName?: string): void; loadPageTranslations(locale: string, routeName: string, data: import("@i18n-micro/types").Translations): void; mergeTranslation(locale: string, routeName: string, newTranslations: import("@i18n-micro/types").Translations, _force?: boolean): void; clearCache(): void; }; }
reset(options?: ResetI18nOptions & { reseed?: boolean; }) => void
setTranslationsFromJson(loc: string, translations: Record<string, unknown>) => Promise<void>
Locale — 7 members
MemberType
baseDefault?boolean | undefined
baseUrl?string | undefined
codestring
dir?"ltr" | "rtl" | "auto" | undefined
disabled?boolean | undefined
displayName?string | undefined
iso?string | undefined
NuxtI18nMockHarness — 5 members
MemberType
contextI18nTestContext
i18n{ $i18nStrategy: { getStrategy: () => import("./context").TestStrategy; getDefaultLocale: () => string; getLocales: () => import("./context").Locale[]; getLocalizedRouteNamePrefix: () => string; getGlobalLocaleRoutes: () => undefined; getRouteLocales: () => undefined; getRoutesLocaleLinks: () => undefined; getNoPrefixRedirect: () => undefined; getRouteBaseName: () => null; formatPathForResolve: (path: string) => string; setRouter: () => void; getCanonicalPath: () => null; getRedirect: () => null; shouldReturn404: () => null; getClientRedirect: () => null; resolveLocaleFromPath(path: string): string | null; getLocaleFromPath(path: string): string | null; getCurrentLocale: () => string; getPluginRouteName: () => string; getCurrentLocaleName: () => string | null; localeRoute(targetLocale: string, routeOrPath: unknown): { path: string; fullPath: string; }; switchLocaleRoute(_fromLocale: string, toLocale: string, route?: unknown): { path: string; fullPath: string; }; }; $getI18nConfig: () => { locales: import("./context").Locale[]; defaultLocale: string | undefined; strategy: import("./context").TestStrategy; }; $getLocale: (_route?: unknown) => string; $setLocale: (val: string) => void; $getLocaleName: () => string | null; $setLocaleName: (val: string | null) => void; $getLocales: () => import("./context").Locale[]; $setLocales: (val: import("./context").Locale[]) => void; $defaultLocale: () => string | undefined; $setDefaultLocale: (val: string | undefined) => void; $getRouteName: (_route?: unknown, _locale?: string) => string; $settRouteName: (val: string) => void; $setRouteName: (val: string) => void; $t: (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => import("@i18n-micro/types").Translation; $_t: (route: unknown) => (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => import("@i18n-micro/types").Translation; $ts: (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => string; $_ts: (route: unknown) => (key: import("@i18n-micro/types").TranslationKey, params?: import("@i18n-micro/types").Params, defaultValue?: string | null) => string; $tc: (key: import("@i18n-micro/types").TranslationKey, params: number | import("@i18n-micro/types").Params, defaultValue?: string) => string; $tn: (value: number, options?: Intl.NumberFormatOptions) => string; $td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; $tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; $has: (key: import("@i18n-micro/types").TranslationKey) => boolean; $resolveTranslations: () => Record<string, unknown>; $setTranslation: (key: import("@i18n-micro/types").TranslationKey, value: unknown) => void; $mergeTranslations: (newTranslations: import("@i18n-micro/types").Translations) => void; $switchLocaleRoute: (loc: string) => { path: string; name: string; }; $switchLocalePath: (loc: string) => string; $switchLocale: (val: string) => void; $switchRoute: (route: unknown, toLocale?: string) => void; $localeRoute: (to: unknown, loc?: string) => { name?: string | symbol | undefined; path: string; }; $localePath: (to: unknown, loc?: string) => string; $setI18nRouteParams: (value: unknown) => unknown; $loadPageTranslations: (loc: string, page: string, translations: import("@i18n-micro/types").Translations) => Promise<void>; $setMissingHandler: (handler: import("@i18n-micro/types").MissingHandler | null) => void; $setTranslationsFromJson: (loc: string, translations: Record<string, unknown>) => Promise<void>; helper: { hasCache(locale: string, page: string): boolean; getCache(locale: string, routeName: string): import("@i18n-micro/types").Translations | undefined; setCache(_locale: string, _routeName: string, _cache: Map<string, unknown>): void; hasTranslation(locale: string, key: string): boolean; hasPageTranslation(locale: string, routeName: string): boolean; getTranslation<T = unknown>(locale: string, routeName: string, key: string): T | null; loadTranslations(locale: string, data: import("@i18n-micro/types").Translations, routeName?: string): void; setTranslations(locale: string, data: import("@i18n-micro/types").Translations, routeName?: string): void; loadPageTranslations(locale: string, routeName: string, data: import("@i18n-micro/types").Translations): void; mergeTranslation(locale: string, routeName: string, newTranslations: import("@i18n-micro/types").Translations, _force?: boolean): void; clearCache(): void; }; }
reset(options?: ResetI18nOptions & { reseed?: boolean; }) => void
setTranslationsFromJson(loc: string, translations: Record<string, unknown>) => Promise<void>
useI18n() => ReturnType<I18nTestContext["createFake"]>
ResetI18nOptions — 8 members
MemberType
defaultLocale?string | undefined
locale?string | undefined
localeName?string | null | undefined
locales?Locale[] | undefined
messages?Record<string, Record<string, unknown>> | undefined
routeName?string | undefined
strategy?TestStrategy | undefined
translations?Record<string, unknown> | undefined
SetupNuxtI18nMockOptions — 12 members
MemberType
autoReset?boolean | undefined
beforeEach?((fn: () => void) => void) | undefined
defaultLocale?string | undefined
isolated?boolean | undefined
locale?string | undefined
localeName?string | null | undefined
locales?Locale[] | undefined
messages?Record<string, Record<string, unknown>> | undefined
routeName?string | undefined
spy?SpyFn | undefined
strategy?TestStrategy | undefined
translations?Record<string, unknown> | undefined
## `@i18n-micro/test-utils/publish-smoke`
ts
import { /* … */ } from '@i18n-micro/test-utils/publish-smoke'
ExportKindSignature
ExportTargetinterface3 members
getLoadedModulefunction(mods: Record<string, Record<string, unknown>>, key: string) => Record<string, unknown>
loadResolvedExportfunction(item: ResolvedExport, packageRequire: NodeRequire) => Promise<Record<string, unknown>>
packageRootFromImportMetafunction(importMetaUrl: string, levelsUp?: number) => string
PublishFormattype'esm' | 'cjs'
resolveExportTargetsfunction(pkg: { exports?: unknown; }, targets: ExportTarget[], packageRoot: string) => ResolvedExport[]
smokeLoadExportsfunction(packageRoot: string, pkg: { exports?: unknown; }, targets: ExportTarget[]) => Promise<Record<string, Record<string, unknown>>>
ExportTarget — 3 members
MemberType
condition?"import" | "require" | "default" | undefined
formats?PublishFormat[] | undefined
subpathstring

Back to all packages · Integration guides

Released under the MIT License.