Skip to content

Latest commit

 

History

History
37 lines (23 loc) · 976 Bytes

no-shallow.md

File metadata and controls

37 lines (23 loc) · 976 Bytes

Disallow shallow rendering components (no-shallow)

The user should prefer Full DOM rendering over shallow rendering components.

With shallow rendering, I can refactor my component’s implementation and my tests break. With shallow rendering, I can break my application and my tests say everything’s still working.

Kent C. Dodds

More information: Why I Never Use Shallow Rendering by Kent C. Dodds

Rule Details

The following patterns are considered warnings:

import { shallow } from 'enzyme';

const { shallow } =  require('enzyme');

import enzyme from 'enzyme';
enzyme.shallow(<Component />);

const enzyme = require('enzyme');
enzyme.shallow(<Component />)

The following patterns are not considered warnings:

import { mount } from 'enzyme';

import enzyme from 'enzyme';

const { mount } = require('enzyme');

const enzyme = require('enzyme');