Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-jest

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-jest

Jest Vue transform

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is vue-jest?

vue-jest is a Jest transformer for Vue single-file components (SFCs). It allows you to use Jest to test Vue components by transforming the .vue files into a format that Jest can understand.

What are vue-jest's main functionalities?

Transform Vue SFCs

This feature allows Jest to transform Vue single-file components (.vue files) so that they can be tested. The code sample shows how to configure Jest to use vue-jest for transforming .vue files.

module.exports = { transform: { '^.+\.vue$': 'vue-jest' } };

Mocking Vue Components

This feature allows you to mock Vue components and their dependencies during testing. The code sample demonstrates how to use vue-jest with @vue/test-utils to shallow mount a component and mock a translation function.

import { shallowMount } from '@vue/test-utils';
import MyComponent from '@/components/MyComponent.vue';

test('renders a message', () => {
  const wrapper = shallowMount(MyComponent, {
    mocks: {
      $t: msg => msg
    }
  });
  expect(wrapper.text()).toContain('Hello World');
});

Snapshot Testing

This feature allows you to perform snapshot testing on Vue components. The code sample shows how to use vue-jest with @vue/test-utils to create a snapshot of a component's rendered HTML and compare it to a saved snapshot.

import { shallowMount } from '@vue/test-utils';
import MyComponent from '@/components/MyComponent.vue';

test('matches snapshot', () => {
  const wrapper = shallowMount(MyComponent);
  expect(wrapper.html()).toMatchSnapshot();
});

Other packages similar to vue-jest

Keywords

FAQs

Package last updated on 03 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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