File tree Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -134,8 +134,9 @@ describe("ReComponent", () => {
134134 } ) ;
135135
136136 it ( "does not throw errors in production" , ( ) => {
137+ let originalNodeEnv = process . env . NODE_ENV ;
137138 try {
138- global . __DEV__ = false ;
139+ process . env . NODE_ENV = "production" ;
139140
140141 let click ;
141142 class Example extends ReComponent {
@@ -156,7 +157,7 @@ describe("ReComponent", () => {
156157 ReactDOM . render ( < Example /> , container ) ;
157158 expect ( ( ) => click ( ) ) . not . toThrowError ( ) ;
158159 } finally {
159- global . __DEV__ = true ;
160+ process . env . NODE_ENV = originalNodeEnv ;
160161 }
161162 } ) ;
162163} ) ;
Original file line number Diff line number Diff line change 1- // This is necessary to simulate the development environment where errors should
2- // be reported.
3- global . __DEV__ = true ;
4-
51export function click ( element ) {
62 element . dispatchEvent ( new Event ( "click" , { bubbles : true } ) ) ;
73}
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ export function Re(Component) {
1111 constructor ( props ) {
1212 super ( props ) ;
1313
14- if ( __DEV__ ) {
14+ if ( process . env . NODE_ENV !== "production" ) {
1515 if ( typeof this . reducer !== "function" ) {
1616 const name = this . displayName || this . constructor . name ;
1717 throw new Error (
@@ -27,7 +27,7 @@ export function Re(Component) {
2727 const originalSetState = this . setState ;
2828 let setState = this . setState ;
2929
30- if ( __DEV__ ) {
30+ if ( process . env . NODE_ENV !== "production" ) {
3131 this . setState = ( ) => {
3232 const name = this . displayName || this . constructor . name ;
3333 throw new Error (
@@ -86,7 +86,7 @@ export function Re(Component) {
8686 const updater = state => {
8787 const reduced = this . reducer ( action , state ) ;
8888
89- if ( __DEV__ ) {
89+ if ( process . env . NODE_ENV !== "production" ) {
9090 if ( typeof reduced === "undefined" ) {
9191 const name = this . displayName || this . constructor . name ;
9292 throw new Error (
@@ -113,7 +113,7 @@ export function Re(Component) {
113113 sideEffects = reduced . sideEffects ;
114114 break ;
115115 default : {
116- if ( __DEV__ ) {
116+ if ( process . env . NODE_ENV !== "production" ) {
117117 const name = this . displayName || this . constructor . name ;
118118 throw new Error (
119119 name +
You can’t perform that action at this time.
0 commit comments