From 3f9b924c5c9a2633ff7fc0a9e9b667ab365a6c5e Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Tue, 24 Oct 2017 14:26:13 -0700 Subject: [PATCH 1/3] Added an automated test that would have caught the recent error code transform bug --- .../__tests__/dev-expression-with-codes-test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/error-codes/__tests__/dev-expression-with-codes-test.js b/scripts/error-codes/__tests__/dev-expression-with-codes-test.js index 958e32aa85d..2ff78e492d9 100644 --- a/scripts/error-codes/__tests__/dev-expression-with-codes-test.js +++ b/scripts/error-codes/__tests__/dev-expression-with-codes-test.js @@ -93,4 +93,12 @@ ${expectedInvariantTransformResult}` `_prodInvariant('18', 'Foo', 'Bar') : void 0;` ); }); + + it('should correctly transform invariants that are not in the error codes map', () => { + compare( + "invariant(condition, 'This is not a real error message.');", + "var _prodInvariant = require('reactProdInvariant');\n\n" + + "!condition ? invariant(false, 'This is not a real error message.') : void 0;" + ); + }); }); From 6c93e5b8ff17cc20e411412c716c87e08fab1019 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Tue, 24 Oct 2017 15:47:07 -0700 Subject: [PATCH 2/3] Renamed dev-expression-with-codes test to replace-invariant-error-codes --- ...n-with-codes-test.js => replace-invariant-error-codes-test.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/error-codes/__tests__/{dev-expression-with-codes-test.js => replace-invariant-error-codes-test.js} (100%) diff --git a/scripts/error-codes/__tests__/dev-expression-with-codes-test.js b/scripts/error-codes/__tests__/replace-invariant-error-codes-test.js similarity index 100% rename from scripts/error-codes/__tests__/dev-expression-with-codes-test.js rename to scripts/error-codes/__tests__/replace-invariant-error-codes-test.js From 1fa3a9103af7884667bfb8115803d84659d32088 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Tue, 24 Oct 2017 18:51:40 -0700 Subject: [PATCH 3/3] Formatting nit --- .../__tests__/replace-invariant-error-codes-test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/error-codes/__tests__/replace-invariant-error-codes-test.js b/scripts/error-codes/__tests__/replace-invariant-error-codes-test.js index 2ff78e492d9..11e8a35c2f6 100644 --- a/scripts/error-codes/__tests__/replace-invariant-error-codes-test.js +++ b/scripts/error-codes/__tests__/replace-invariant-error-codes-test.js @@ -97,8 +97,9 @@ ${expectedInvariantTransformResult}` it('should correctly transform invariants that are not in the error codes map', () => { compare( "invariant(condition, 'This is not a real error message.');", - "var _prodInvariant = require('reactProdInvariant');\n\n" + - "!condition ? invariant(false, 'This is not a real error message.') : void 0;" + `var _prodInvariant = require('shared/reactProdInvariant'); + +!condition ? invariant(false, 'This is not a real error message.') : void 0;` ); }); });