Socket
Socket
Sign inDemoInstall

vitest-environment-nuxt

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vitest-environment-nuxt - npm Package Compare versions

Comparing version 0.8.4 to 0.8.5

64

dist/utils.d.ts

@@ -10,6 +10,68 @@ import { EventHandler } from 'h3';

type OptionalFunction<T> = T | (() => Awaitable<T>);
/**
* `registerEndpoint` allows you create Nitro endpoint that returns mocked data. It can come in handy if you want to test a component that makes requests to API to display some data.
*
* @param url - endpoint name (e.g. `/test/`).
* @param handler - factory function that returns the mocked data.
* @example
* ```ts
* import { registerEndpoint } from 'nuxt-vitest/utils'
*
* registerEndpoint("/test/", () => {
* test: "test-field"
* })
* ```
* @see https://github.com/danielroe/nuxt-vitest#registerendpoint
*/
declare function registerEndpoint(url: string, handler: EventHandler): void;
/**
* `mockNuxtImport` allows you to mock Nuxt's auto import functionality.
*
* @param _name - name of an import to mock.
* @param _factory - factory function that returns mocked import.
* @example
* ```ts
* import { mockNuxtImport } from 'nuxt-vitest/utils'
*
* mockNuxtImport('useStorage', () => {
* return () => {
* return { value: 'mocked storage' }
* }
* })
* ```
* @see https://github.com/danielroe/nuxt-vitest#mocknuxtimport
*/
declare function mockNuxtImport<T = any>(_name: string, _factory: () => T | Promise<T>): void;
/**
* Mock a component, the first argument can be the relative path to the component, or the component name in PascalCase.
* `mockComponent` allows you to mock Nuxt's component.
*
* @param path - component name in PascalCase, or the relative path of the component.
* @param setup - factory function that returns the mocked component.
* @example
* ```ts
* import { mockComponent } from 'nuxt-vitest/utils'
*
* mockComponent('MyComponent', {
* props: {
* value: String
* },
* setup(props) {
* // ...
* }
* })
*
* // relative path or alias also works
* mockComponent('~/components/my-component.vue', async () => {
* // or a factory function
* return {
* setup(props) {
* // ...
* }
* }
* })
*
* // or you can use SFC for redirecting to a mock component
* mockComponent('MyComponent', () => import('./MockComponent.vue'))
* ```
* @see https://github.com/danielroe/nuxt-vitest#mockcomponent
*/

@@ -16,0 +78,0 @@ declare function mockComponent<Props, RawBindings = object>(path: string, setup: OptionalFunction<(props: Readonly<Props>, ctx: SetupContext) => RawBindings | RenderFunction>): void;

2

package.json
{
"name": "vitest-environment-nuxt",
"version": "0.8.4",
"version": "0.8.5",
"description": "An vitest environment with support for testing code that needs a Nuxt runtime environment.",

@@ -5,0 +5,0 @@ "repository": "danielroe/vitest-environment-nuxt",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc