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

@wojtekmaj/enzyme-adapter-react-17

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wojtekmaj/enzyme-adapter-react-17

JavaScript Testing utilities for React

  • 0.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @wojtekmaj/enzyme-adapter-react-17?

@wojtekmaj/enzyme-adapter-react-17 is an adapter for Enzyme that allows it to work with React 17. Enzyme is a JavaScript testing utility for React that makes it easier to assert, manipulate, and traverse your React Components' output.

What are @wojtekmaj/enzyme-adapter-react-17's main functionalities?

Mounting Components

This feature allows you to mount a React component and inspect its output. The `mount` function renders the full DOM including child components, which is useful for testing component lifecycle and interactions.

const Enzyme = require('enzyme');
const Adapter = require('@wojtekmaj/enzyme-adapter-react-17');
const { mount } = Enzyme;
const React = require('react');
const MyComponent = require('./MyComponent');

Enzyme.configure({ adapter: new Adapter() });

const wrapper = mount(<MyComponent />);
console.log(wrapper.debug());

Shallow Rendering

Shallow rendering is useful for unit testing React components in isolation. The `shallow` function renders only the component itself without rendering its children, making it easier to test the component's behavior.

const Enzyme = require('enzyme');
const Adapter = require('@wojtekmaj/enzyme-adapter-react-17');
const { shallow } = Enzyme;
const React = require('react');
const MyComponent = require('./MyComponent');

Enzyme.configure({ adapter: new Adapter() });

const wrapper = shallow(<MyComponent />);
console.log(wrapper.debug());

Finding Elements

This feature allows you to find elements within a rendered component. The `find` function can be used to search for elements by tag, class, or other attributes, making it easier to test specific parts of the component.

const Enzyme = require('enzyme');
const Adapter = require('@wojtekmaj/enzyme-adapter-react-17');
const { shallow } = Enzyme;
const React = require('react');
const MyComponent = require('./MyComponent');

Enzyme.configure({ adapter: new Adapter() });

const wrapper = shallow(<MyComponent />);
const button = wrapper.find('button');
console.log(button.length);

Other packages similar to @wojtekmaj/enzyme-adapter-react-17

Keywords

FAQs

Package last updated on 09 Nov 2022

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