Browse Source

test(enzyme): Change setting for `disableLifecycleMethods` to be default (false) (#15071)

This behavior is confusing for people that would expect lifecycle methods to fire in tests.
Billy Vong 5 years ago
parent
commit
8f8615632b

+ 0 - 1
tests/js/setup.js

@@ -20,7 +20,6 @@ fromEntries.shim();
  * Enzyme configuration
  */
 Enzyme.configure({adapter: new Adapter()});
-Enzyme.configure({disableLifecycleMethods: true});
 
 /**
  * Mock (current) date to alway be below

+ 10 - 3
tests/js/spec/components/forms/rangeField.spec.jsx

@@ -6,7 +6,9 @@ import {RangeField} from 'app/components/forms';
 describe('RangeField', function() {
   describe('render()', function() {
     it('renders', function() {
-      const wrapper = shallow(<RangeField name="fieldName" />);
+      const wrapper = shallow(<RangeField name="fieldName" />, {
+        disableLifecycleMethods: true,
+      });
       expect(wrapper).toMatchSnapshot();
     });
 
@@ -19,18 +21,22 @@ describe('RangeField', function() {
           step={1}
           snap={false}
           allowedValues={[1, 2, 3]}
-        />
+        />,
+        {disableLifecycleMethods: true}
       );
       expect(wrapper).toMatchSnapshot();
     });
 
     it('renders with value', function() {
-      const wrapper = shallow(<RangeField name="fieldName" value={2} />);
+      const wrapper = shallow(<RangeField name="fieldName" value={2} />, {
+        disableLifecycleMethods: true,
+      });
       expect(wrapper).toMatchSnapshot();
     });
 
     it('renders with form context', function() {
       const wrapper = shallow(<RangeField name="fieldName" />, {
+        disableLifecycleMethods: true,
         context: {
           form: {
             data: {
@@ -45,6 +51,7 @@ describe('RangeField', function() {
 
     it('renders with value=0 in form context', function() {
       const wrapper = shallow(<RangeField name="fieldName" />, {
+        disableLifecycleMethods: true,
         context: {
           form: {
             data: {

+ 1 - 0
tests/js/spec/components/issueDiff.spec.jsx

@@ -13,6 +13,7 @@ describe('IssueDiff', function() {
   it('is loading when initially rendering', function() {
     const wrapper = shallow(
       <IssueDiff
+        api={api}
         baseIssueId="base"
         targetIssueId="target"
         orgId="org-slug"

+ 2 - 2
tests/js/spec/views/discover/result/table.spec.jsx

@@ -1,12 +1,12 @@
 import React from 'react';
-import {shallow, render} from 'sentry-test/enzyme';
+import {mount, render} from 'sentry-test/enzyme';
 
 import {ResultTable} from 'app/views/discover/result/table';
 
 describe('ResultTable', function() {
   let wrapper;
   beforeEach(function() {
-    wrapper = shallow(
+    wrapper = mount(
       <ResultTable
         organization={TestStubs.Organization({
           projects: [TestStubs.Project({id: '1'})],

+ 8 - 2
tests/js/spec/views/inviteMember/inviteMember.spec.jsx

@@ -54,7 +54,10 @@ describe('InviteMember', function() {
   });
 
   it('should render loading', function() {
-    const wrapper = shallow(<InviteMember {...baseProps} />, baseContext);
+    const wrapper = shallow(<InviteMember {...baseProps} />, {
+      ...baseContext,
+      disableLifecycleMethods: true,
+    });
     expect(wrapper).toMatchSnapshot();
   });
 
@@ -90,7 +93,10 @@ describe('InviteMember', function() {
       invitesEnabled: false,
     }));
 
-    const wrapper = shallow(<InviteMember {...baseProps} />, baseContext);
+    const wrapper = shallow(<InviteMember {...baseProps} />, {
+      ...baseContext,
+      disableLifecycleMethods: true,
+    });
     wrapper.setState({
       loading: false,
     });

+ 5 - 1
tests/js/spec/views/organizationGroupDetails/groupSimilar.spec.jsx

@@ -44,7 +44,11 @@ describe('Issues Similar View', function() {
 
   it('renders initially with loading component', function() {
     const component = shallow(
-      <GroupSimilar project={project} params={{groupId: 'group-id'}} location={{}} />,
+      <GroupSimilar
+        project={project}
+        params={{orgId: 'org-slug', groupId: 'group-id'}}
+        location={{}}
+      />,
       routerContext
     );