diff --git a/.travis.yml b/.travis.yml index eee9d224..22a20535 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: - - "10.18.1" - # - "node" + # - "10.18.1" + - "node" env: - NODE_ENV=TEST cache: @@ -12,12 +12,13 @@ before_script: - yarn global add if-node-version script: - yarn build || travis_terminate 1 - - if-node-version 10 || { yarn test && travis_terminate 0; } - - yarn coveralls + - yarn test || travis_terminate 1 + - yarn coveralls || travis_terminate 0 jobs: include: - stage: deploy if: branch == master && !fork script: + - yarn test || travis_terminate 1 - NODE_ENV= yarn build || travis_terminate 1 - yarn semantic-release diff --git a/__tests__/__prod_snapshots__/base.js.snap b/__tests__/__prod_snapshots__/base.js.snap index fa6431a0..4ffc6b65 100644 --- a/__tests__/__prod_snapshots__/base.js.snap +++ b/__tests__/__prod_snapshots__/base.js.snap @@ -2,9 +2,9 @@ exports[`base functionality - es5 (autofreeze) async recipe function works with rejected promises 1`] = `"[Immer] minified error nr: 3 {\\"a\\":0,\\"b\\":1}. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - es5 (autofreeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`; @@ -18,19 +18,17 @@ exports[`base functionality - es5 (autofreeze) revokes the draft once produce re exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 4`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; - -exports[`base functionality - es5 (autofreeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - es5 (autofreeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - es5 (autofreeze)(patch listener) async recipe function works with rejected promises 1`] = `"[Immer] minified error nr: 3 {\\"a\\":0,\\"b\\":1}. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (autofreeze)(patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (autofreeze)(patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (autofreeze)(patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (autofreeze)(patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - es5 (autofreeze)(patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`; @@ -44,19 +42,17 @@ exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 4`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (autofreeze)(patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; - -exports[`base functionality - es5 (autofreeze)(patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (autofreeze)(patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (autofreeze)(patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (autofreeze)(patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - es5 (autofreeze)(patch listener) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - es5 (no freeze) async recipe function works with rejected promises 1`] = `"[Immer] minified error nr: 3 {\\"a\\":0,\\"b\\":1}. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (no freeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (no freeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (no freeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (no freeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - es5 (no freeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`; @@ -70,19 +66,17 @@ exports[`base functionality - es5 (no freeze) revokes the draft once produce ret exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 4`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; - -exports[`base functionality - es5 (no freeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - es5 (no freeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - es5 (patch listener) async recipe function works with rejected promises 1`] = `"[Immer] minified error nr: 3 {\\"a\\":0,\\"b\\":1}. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - es5 (patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`; @@ -96,19 +90,17 @@ exports[`base functionality - es5 (patch listener) revokes the draft once produc exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 4`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; - -exports[`base functionality - es5 (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - es5 (patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - es5 (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - es5 (patch listener) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - proxy (autofreeze) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`; -exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - proxy (autofreeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`; @@ -130,11 +122,9 @@ exports[`base functionality - proxy (autofreeze) revokes the draft once produce exports[`base functionality - proxy (autofreeze) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`; -exports[`base functionality - proxy (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - proxy (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; - -exports[`base functionality - proxy (autofreeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - proxy (autofreeze) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] minified error nr: 11. Find the full error at: https://bit.ly/3cXEKWf"`; @@ -144,9 +134,9 @@ exports[`base functionality - proxy (autofreeze) throws when the draft is modifi exports[`base functionality - proxy (autofreeze)(patch listener) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`; -exports[`base functionality - proxy (autofreeze)(patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (autofreeze)(patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - proxy (autofreeze)(patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (autofreeze)(patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - proxy (autofreeze)(patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`; @@ -168,11 +158,9 @@ exports[`base functionality - proxy (autofreeze)(patch listener) revokes the dra exports[`base functionality - proxy (autofreeze)(patch listener) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`; -exports[`base functionality - proxy (autofreeze)(patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; - -exports[`base functionality - proxy (autofreeze)(patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (autofreeze)(patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - proxy (autofreeze)(patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (autofreeze)(patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - proxy (autofreeze)(patch listener) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] minified error nr: 11. Find the full error at: https://bit.ly/3cXEKWf"`; @@ -182,9 +170,9 @@ exports[`base functionality - proxy (autofreeze)(patch listener) throws when the exports[`base functionality - proxy (no freeze) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`; -exports[`base functionality - proxy (no freeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (no freeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - proxy (no freeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (no freeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - proxy (no freeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`; @@ -206,11 +194,9 @@ exports[`base functionality - proxy (no freeze) revokes the draft once produce r exports[`base functionality - proxy (no freeze) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`; -exports[`base functionality - proxy (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - proxy (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; - -exports[`base functionality - proxy (no freeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - proxy (no freeze) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] minified error nr: 11. Find the full error at: https://bit.ly/3cXEKWf"`; @@ -220,9 +206,9 @@ exports[`base functionality - proxy (no freeze) throws when the draft is modifie exports[`base functionality - proxy (patch listener) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`; -exports[`base functionality - proxy (patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - proxy (patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - proxy (patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`; @@ -244,11 +230,9 @@ exports[`base functionality - proxy (patch listener) revokes the draft once prod exports[`base functionality - proxy (patch listener) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`; -exports[`base functionality - proxy (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; - -exports[`base functionality - proxy (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`base functionality - proxy (patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`base functionality - proxy (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`; exports[`base functionality - proxy (patch listener) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] minified error nr: 11. Find the full error at: https://bit.ly/3cXEKWf"`; diff --git a/__tests__/__prod_snapshots__/patch.js.snap b/__tests__/__prod_snapshots__/patch.js.snap index 47a33c20..184c445d 100644 --- a/__tests__/__prod_snapshots__/patch.js.snap +++ b/__tests__/__prod_snapshots__/patch.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`applyPatches throws when \`op\` is not "add", "replace", nor "remove" 1`] = `"[Immer] minified error nr: 17 copy. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`applyPatches throws when \`op\` is not "add", "replace", nor "remove" 1`] = `"[Immer] minified error nr: 17 'copy'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`applyPatches throws when \`path\` cannot be resolved 1`] = `"[Immer] minified error nr: 15 a/b. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`applyPatches throws when \`path\` cannot be resolved 1`] = `"[Immer] minified error nr: 15 'a/b'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`applyPatches throws when \`path\` cannot be resolved 2`] = `"[Immer] minified error nr: 15 a/b/c. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`applyPatches throws when \`path\` cannot be resolved 2`] = `"[Immer] minified error nr: 15 'a/b/c'. Find the full error at: https://bit.ly/3cXEKWf"`; diff --git a/__tests__/__prod_snapshots__/plugins.js.snap b/__tests__/__prod_snapshots__/plugins.js.snap index 61bee22e..15975f90 100644 --- a/__tests__/__prod_snapshots__/plugins.js.snap +++ b/__tests__/__prod_snapshots__/plugins.js.snap @@ -1,11 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ES5 plugins should throw if no proxies are available error when using ES5 1`] = `"[Immer] minified error nr: 19 ES5. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`ES5 plugins should throw if no proxies are available error when using ES5 1`] = `"[Immer] minified error nr: 18 'ES5'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`error when using Maps 1`] = `"[Immer] minified error nr: 19 MapSet. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`error when using Maps 1`] = `"[Immer] minified error nr: 18 'MapSet'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`error when using patches - 1 1`] = `"[Immer] minified error nr: 19 Patches. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`error when using patches - 1 1`] = `"[Immer] minified error nr: 18 'Patches'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`error when using patches - 2 1`] = `"[Immer] minified error nr: 19 Patches. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`error when using patches - 2 1`] = `"[Immer] minified error nr: 18 'Patches'. Find the full error at: https://bit.ly/3cXEKWf"`; -exports[`error when using patches - 3 1`] = `"[Immer] minified error nr: 19 Patches. Find the full error at: https://bit.ly/3cXEKWf"`; +exports[`error when using patches - 3 1`] = `"[Immer] minified error nr: 18 'Patches'. Find the full error at: https://bit.ly/3cXEKWf"`; diff --git a/__tests__/base.js b/__tests__/base.js index 3382ffa5..29721c1c 100644 --- a/__tests__/base.js +++ b/__tests__/base.js @@ -16,6 +16,8 @@ jest.setTimeout(1000) enableAllPlugins() +const isProd = process.env.NODE_ENV === "production" + test("immer should have no dependencies", () => { expect(require("../package.json").dependencies).toBeUndefined() }) @@ -1145,65 +1147,66 @@ function runBaseTest(name, useProxies, autoFreeze, useListener) { }) // NOTE: ES5 drafts only protect existing properties when revoked. - it("revokes the draft once produce returns", () => { - const expectRevoked = (fn, shouldThrow = true) => { - if (shouldThrow) expect(fn).toThrowErrorMatchingSnapshot() - else expect(fn).not.toThrow() - } + if (!isProd) + it("revokes the draft once produce returns", () => { + const expectRevoked = (fn, shouldThrow = true) => { + if (shouldThrow) expect(fn).toThrowErrorMatchingSnapshot() + else expect(fn).not.toThrow() + } - // Test object drafts: - let draft - produce({a: 1, b: 1}, s => { - draft = s - delete s.b - }) + // Test object drafts: + let draft + produce({a: 1, b: 1}, s => { + draft = s + delete s.b + }) - // Access known property on object draft. - expectRevoked(() => { - draft.a - }) + // Access known property on object draft. + expectRevoked(() => { + draft.a + }) - // Assign known property on object draft. - expectRevoked(() => { - draft.a = true - }) + // Assign known property on object draft. + expectRevoked(() => { + draft.a = true + }) - // Access unknown property on object draft. - expectRevoked(() => { - draft.z - }, useProxies) + // Access unknown property on object draft. + expectRevoked(() => { + draft.z + }, useProxies) - // Assign unknown property on object draft. - expectRevoked(() => { - draft.z = true - }, useProxies) + // Assign unknown property on object draft. + expectRevoked(() => { + draft.z = true + }, useProxies) - // Test array drafts: - produce([1, 2], s => { - draft = s - s.pop() - }) + // Test array drafts: + produce([1, 2], s => { + draft = s + s.pop() + }) - // Access known index of an array draft. - expectRevoked(() => { - draft[0] - }) + // Access known index of an array draft. + expectRevoked(() => { + draft[0] + }) - // Assign known index of an array draft. - expectRevoked(() => { - draft[0] = true - }) + // Assign known index of an array draft. + expectRevoked(() => { + draft[0] = true + }) - // Access unknown index of an array draft. - expectRevoked(() => { - draft[1] - }, useProxies) + // Access unknown index of an array draft. + expectRevoked(() => { + draft[1] + }, useProxies) - // Assign unknown index of an array draft. - expectRevoked(() => { - draft[1] = true - }, useProxies) - }) + // Assign unknown index of an array draft. + expectRevoked(() => { + draft[1] = true + }, useProxies) + }) it("can access a child draft that was created before the draft was modified", () => { produce({a: {}}, s => { @@ -1697,7 +1700,7 @@ function runBaseTest(name, useProxies, autoFreeze, useListener) { }, e => { expect(e).toBe(err) - expect(() => draft.a).toThrowErrorMatchingSnapshot() + if (!isProd) expect(() => draft.a).toThrowErrorMatchingSnapshot() } ) }) @@ -2418,7 +2421,9 @@ function testLiteralTypes(produce) { draft.foo = true }) ).toThrowError( - "produce can only be called on things that are draftable" + isProd + ? "[Immer] minified error nr: 21" + : "produce can only be called on things that are draftable" ) }) } else { diff --git a/__tests__/current.js b/__tests__/current.js index fc1ed18a..add87990 100644 --- a/__tests__/current.js +++ b/__tests__/current.js @@ -14,6 +14,8 @@ enableAllPlugins() runTests("proxy", true) runTests("es5", false) +const isProd = process.env.NODE_ENV === "production" + function runTests(name, useProxies) { describe("current - " + name, () => { beforeAll(() => { @@ -24,7 +26,11 @@ function runTests(name, useProxies) { it("must be called on draft", () => { expect(() => { current({}) - }).toThrowError("[Immer] 'current' expects a draft, got: [object Object]") + }).toThrowError( + isProd + ? "[Immer] minified error nr: 22 '[object Object]'. Find the full error at: https://bit.ly/3cXEKWf" + : "[Immer] 'current' expects a draft, got: [object Object]" + ) }) it("can handle simple arrays", () => { diff --git a/__tests__/manual.js b/__tests__/manual.js index 10d1b768..265f44c0 100644 --- a/__tests__/manual.js +++ b/__tests__/manual.js @@ -10,6 +10,8 @@ import { enableAllPlugins() +const isProd = process.env.NODE_ENV === "production" + runTests("proxy", true) runTests("es5", false) @@ -41,16 +43,17 @@ function runTests(name, useProxies) { expect(state).toEqual([{}, {}, {}]) }) - it("cannot modify after finish", () => { - const state = {a: 1} + if (!isProd) + it("cannot modify after finish", () => { + const state = {a: 1} - const draft = createDraft(state) - draft.a = 2 - expect(finishDraft(draft)).toEqual({a: 2}) - expect(() => { - draft.a = 3 - }).toThrowErrorMatchingSnapshot() - }) + const draft = createDraft(state) + draft.a = 2 + expect(finishDraft(draft)).toEqual({a: 2}) + expect(() => { + draft.a = 3 + }).toThrowErrorMatchingSnapshot() + }) it("should support patches drafts", () => { const state = {a: 1} diff --git a/__tests__/original.js b/__tests__/original.js index 6d645401..89341c47 100644 --- a/__tests__/original.js +++ b/__tests__/original.js @@ -3,6 +3,8 @@ import produce, {original, setUseProxies, enableAllPlugins} from "../src/immer" enableAllPlugins() +const isProd = process.env.NODE_ENV === "production" + describe("original", () => { const baseState = { a: [], @@ -40,20 +42,28 @@ describe("original", () => { draftState.c = {} draftState.d = 3 expect(() => original(draftState.c)).toThrowErrorMatchingInlineSnapshot( - `"[Immer] 'original' expects a draft, got: [object Object]"` + isProd + ? `"[Immer] minified error nr: 23 '[object Object]'. Find the full error at: https://bit.ly/3cXEKWf"` + : `"[Immer] 'original' expects a draft, got: [object Object]"` ) expect(() => original(draftState.d)).toThrowErrorMatchingInlineSnapshot( - `"[Immer] 'original' expects a draft, got: 3"` + isProd + ? `"[Immer] minified error nr: 23 '3'. Find the full error at: https://bit.ly/3cXEKWf"` + : `"[Immer] 'original' expects a draft, got: 3"` ) }) }) it("should return undefined for an object that is not proxied", () => { expect(() => original({})).toThrowErrorMatchingInlineSnapshot( - `"[Immer] 'original' expects a draft, got: [object Object]"` + isProd + ? `"[Immer] minified error nr: 23 '[object Object]'. Find the full error at: https://bit.ly/3cXEKWf"` + : `"[Immer] 'original' expects a draft, got: [object Object]"` ) expect(() => original(3)).toThrowErrorMatchingInlineSnapshot( - `"[Immer] 'original' expects a draft, got: 3"` + isProd + ? `"[Immer] minified error nr: 23 '3'. Find the full error at: https://bit.ly/3cXEKWf"` + : `"[Immer] 'original' expects a draft, got: 3"` ) }) }) diff --git a/ignoreObseleteSnapshots.js b/ignoreObseleteSnapshots.js new file mode 100644 index 00000000..235de126 --- /dev/null +++ b/ignoreObseleteSnapshots.js @@ -0,0 +1,6 @@ +module.exports = function(results) { + // don't count obselete snapshot as a failure, but just check if there are no failing tests + // console.dir(results) + results.success = results.testResults.every(r => r.numFailingTests === 0) + return results +} diff --git a/jest.config.build.js b/jest.config.build.js index c1c112d9..3cf532b9 100644 --- a/jest.config.build.js +++ b/jest.config.build.js @@ -14,5 +14,6 @@ module.exports = { preset: "ts-jest/presets/js-with-ts", testEnvironment: "node", testMatch: ["**/__tests__/**/*.[jt]s?(x)"], - snapshotResolver: "/jest.config.build.snapshots.js" + snapshotResolver: "/jest.config.build.snapshots.js", + testResultsProcessor: "/ignoreObseleteSnapshots.js" } diff --git a/readme.md b/readme.md index 62153f30..32e917a1 100644 --- a/readme.md +++ b/readme.md @@ -10,7 +10,7 @@ Winner of the "Breakthrough of the year" [React open source award](https://osawa ## Contribute using one-click online setup -You can use Gitpod(a free online VS Code like IDE) for contributing online. With a single click it will launch a workspace and automatically: +You can use Gitpod (a free online VS Code like IDE) for contributing online. With a single click it will launch a workspace and automatically: - clone the immer repo. - install the dependencies. diff --git a/src/utils/errors.ts b/src/utils/errors.ts index 5c464519..b73e2aac 100644 --- a/src/utils/errors.ts +++ b/src/utils/errors.ts @@ -53,7 +53,7 @@ export function die(error: keyof typeof errors, ...args: any[]): never { } throw new Error( `[Immer] minified error nr: ${error}${ - args.length ? " " + args.join(",") : "" + args.length ? " " + args.map(s => `'${s}'`).join(",") : "" }. Find the full error at: https://bit.ly/3cXEKWf` ) }