A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://vue-test-utils.vuejs.org/api/ below:

Website Navigation


API | Vue Test Utils

# API # mount()

See options

Creates a Wrapper that contains the mounted and rendered Vue component.

Without options:

With Vue options:

Attach to DOM:

Default and named slots:

Stubbing global properties:

Stubbing components:

Deprecation Notice:

When stubbing components, supplying a string (ComponentToStub: '<div class="stubbed" />) is no longer supported.

# shallowMount()

See options

Like mount, it creates a Wrapper that contains the mounted and rendered Vue component, but with stubbed child components.

Without options:

With Vue options:

Attach to DOM:

Default and named slots:

Stubbing global properties:

# render()

See options

Renders an object to a string and returns a cheerio wrapper .

Cheerio is a jQuery-like library to traverse the DOM in Node.js. It has a similar API to the Vue Test Utils Wrapper.

render uses vue-server-renderer under the hood, to render a component to static HTML.

render is included in the @vue/server-test-utils package.

Without options:

With Vue options:

Default and named slots:

Stubbing global properties:

# renderToString()

See options

Renders a component to HTML.

renderToString uses vue-server-renderer under the hood, to render a component to HTML.

renderToString is included in the @vue/server-test-utils package.

Without options:

With Vue options:

Default and named slots:

Stubbing global properties:

# Selectors

A lot of methods take a selector as an argument. A selector can either be a CSS selector, a Vue component, or a find option object.

# CSS Selectors

Mount handles any valid CSS selector:

You can also use combinators:

# Vue Components

Vue components are also valid selectors.

# Find Option Object # Name

Using a find option object, Vue Test Utils allows for selecting elements by a name of component on wrapper components.

# Ref

Using a find option object, Vue Test Utils allows for selecting elements by $ref on wrapper components.

# createLocalVue()

createLocalVue returns a Vue class for you to add components, mixins and install plugins without polluting the global Vue class.

The errorHandler option can be used to handle uncaught errors during component render function and watchers.

Use it with options.localVue:

Without options:

With the errorHandler option:

# createWrapper(node [, options])

createWrapper creates a Wrapper for a mounted Vue instance, or an HTML element.

# Config

Vue Test Utils includes a config object to defined options used by Vue Test Utils.

# Vue Test Utils Config Options # showDeprecationWarnings

Control whether or not to show deprecation warnings. When set to true, all deprecation warnings are visible in the console.

Example:

# deprecationWarningHandler

Allows fine-grained control on deprecation warnings. When showDeprecationWarnings is set to true, all deprecation warnings will be passed to this handler with method name as first argument and original message as second.

TIP

This could be useful to log deprecation messages to separate location or to help in gradual upgrade of codebase to latest version of test utils by ignoring certain deprecated functions warnings

Example:

# stubs

The stub stored in config.stubs is used by default. Stubs to use in components. These are overwritten by stubs passed in the mounting options.

When passing stubs as an array in the mounting options, config.stubs are converted to an array, and will stub components with a basic component that returns <${component name}-stub>.

Example:

# mocks

Like stubs, the values passed to config.mocks are used by default. Any values passed to the mounting options mocks object will take priority over the ones declared in config.mocks.

Example:

# methods

You can configure default methods using the config object. This can be useful for plugins that inject methods to components, like VeeValidate . You can override methods set in config by passing methods in the mounting options.

Example:

# provide

Like stubs or mocks, the values passed to config.provide are used by default. Any values passed to the mounting options provide object will take priority over the ones declared in config.provide. Please take note that it is not supported to pass a function as config.provide.

Example:

# enableAutoDestroy(hook)

enableAutoDestroy will destroy all created Wrapper instances using the passed hook function (for example afterEach ). After calling the method, you can revert to the default behavior by calling the resetAutoDestroyState method.

# resetAutoDestroyState

After calling enableAutoDestroy you might need to disable auto-destroy behavior (for example when some of your test suites rely on wrapper being persistent across separate tests)

To achieve this you might call resetAutoDestroyState to disable previously registered hook


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4