From cc62d01f028abae907636a0549177651533281d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 28 Mar 2017 21:00:56 +0200 Subject: [PATCH 01/23] Initial commit --- LICENSE | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..5e11caef54 --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2017, Michał Pierzchała +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From e149f93ed9bbd86ab5b875afeb5beaadf2b83396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 28 Mar 2017 21:05:38 +0200 Subject: [PATCH 02/23] Setup package.json --- package.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000000..56043d3d2f --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "jest-zone-patch", + "version": "0.0.1", + "description": "Enables Jest functions to be run within Zone.js context", + "main": "index.js", + "repository": "git@github.com:thymikee/jest-zone-patch.git", + "author": "Michał Pierzchała ", + "license": "BSD-3" +} From 4ad51e9532dc76e10ee601d1da47f16b68d761e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 28 Mar 2017 21:05:53 +0200 Subject: [PATCH 03/23] Add index.js with a patch --- index.js | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000000..0eea5221c4 --- /dev/null +++ b/index.js @@ -0,0 +1,78 @@ +/** + * Patch Jest's describe/test/beforeEach/afterEach functions so test code + * always runs in a testZone (ProxyZone). +*/ + +if (Zone === undefined) throw new Error('Missing: Zone (zone.js)'); +if (jest === undefined) + throw new Error( + 'Missing: jest.\n' + + 'This patch must be included in a script called with ' + + '`setupTestFrameworkScriptFile` in Jest config.', + ); +if (jest['__zone_patch__'] === true) + throw new Error("'jest' has already been patched with 'Zone'."); + +jest['__zone_patch__'] = true; +const SyncTestZoneSpec = Zone['SyncTestZoneSpec']; +const ProxyZoneSpec = Zone['ProxyZoneSpec']; + +if (SyncTestZoneSpec === undefined) + throw new Error('Missing: SyncTestZoneSpec (zone.js/dist/sync-test)'); +if (ProxyZoneSpec === undefined) + throw new Error('Missing: ProxyZoneSpec (zone.js/dist/proxy.js)'); + +const env = global; +const ambientZone = Zone.current; + +// Create a synchronous-only zone in which to run `describe` blocks in order to +// raise an error if any asynchronous operations are attempted +// inside of a `describe` but outside of a `beforeEach` or `it`. +const syncZone = ambientZone.fork(new SyncTestZoneSpec('jest.describe')); +function wrapDescribeInZone(describeBody) { + return () => syncZone.run(describeBody, null, arguments); +} + +// Create a proxy zone in which to run `test` blocks so that the tests function +// can retroactively install different zones. +const testProxyZone = ambientZone.fork(new ProxyZoneSpec()); +function wrapTestInZone(testBody) { + return testBody.length === 0 + ? () => testProxyZone.run(testBody, null) + : done => testProxyZone.run(testBody, null, [done]); +} + +['xdescribe', 'fdescribe', 'describe'].forEach(methodName => { + const originaljestFn = env[methodName]; + env[methodName] = function(description, specDefinitions) { + return originaljestFn.call( + this, + description, + wrapDescribeInZone(specDefinitions), + ); + }; + if (methodName === 'describe') { + env[methodName].only = env['fdescribe']; + env[methodName].skip = env['xdescribe']; + } +}); + +['xit', 'fit', 'test', 'it'].forEach(methodName => { + const originaljestFn = env[methodName]; + env[methodName] = function(description, specDefinitions, timeout) { + arguments[1] = wrapTestInZone(specDefinitions); + return originaljestFn.apply(this, arguments); + }; + if (methodName === 'test' || methodName === 'it') { + env[methodName].only = env['fit']; + env[methodName].skip = env['xit']; + } +}); + +['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(methodName => { + const originaljestFn = env[methodName]; + env[methodName] = function(specDefinitions, timeout) { + arguments[0] = wrapTestInZone(specDefinitions); + return originaljestFn.apply(this, arguments); + }; +}); From f3494756b816fd584b8888dc977601fef8f76dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 28 Mar 2017 21:06:57 +0200 Subject: [PATCH 04/23] v0.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 56043d3d2f..ee55ed4cec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jest-zone-patch", - "version": "0.0.1", + "version": "0.0.2", "description": "Enables Jest functions to be run within Zone.js context", "main": "index.js", "repository": "git@github.com:thymikee/jest-zone-patch.git", From 621d54b62e23fae2a6f2e4315e8dc3ab520486e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 28 Mar 2017 21:10:34 +0200 Subject: [PATCH 05/23] Remove trailing commas --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0eea5221c4..97b10e050b 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,7 @@ if (jest === undefined) throw new Error( 'Missing: jest.\n' + 'This patch must be included in a script called with ' + - '`setupTestFrameworkScriptFile` in Jest config.', + '`setupTestFrameworkScriptFile` in Jest config.' ); if (jest['__zone_patch__'] === true) throw new Error("'jest' has already been patched with 'Zone'."); @@ -48,7 +48,7 @@ function wrapTestInZone(testBody) { return originaljestFn.call( this, description, - wrapDescribeInZone(specDefinitions), + wrapDescribeInZone(specDefinitions) ); }; if (methodName === 'describe') { From cf8aa9c5fc93bb804358b1cee24e8389d74883fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 28 Mar 2017 21:22:47 +0200 Subject: [PATCH 06/23] Create README.md --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000..bc5f168d08 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# jest-zone-patch +Enables Jest functions to be run within Zone.js context, specifically for [Angular](https://angular.io) apps. + +## Usage + +Place it in your `setupJestTestFramework.ts` (or so) file +```js +import 'jest-zone-patch'; +``` + +And run it as Jest's `setupTestFrameworkScriptFile`: + +```json +"jest": { + "setupTestFrameworkScriptFile": "/src/setupJestTestFramework.ts" +} +``` + +It's crucial to run this patch here, because at this point patched functions like `test` or `describe` are available in global scope. From 7068af50e3dbe949c3434c24a075636e1d198064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 28 Mar 2017 21:10:48 +0200 Subject: [PATCH 07/23] v0.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ee55ed4cec..cdf24b36a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jest-zone-patch", - "version": "0.0.2", + "version": "0.0.3", "description": "Enables Jest functions to be run within Zone.js context", "main": "index.js", "repository": "git@github.com:thymikee/jest-zone-patch.git", From 26f12325694a22278e73e87644b62f9fc6da0905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 28 Mar 2017 21:13:48 +0200 Subject: [PATCH 08/23] v0.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cdf24b36a8..310d5ceb47 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jest-zone-patch", - "version": "0.0.3", + "version": "0.0.4", "description": "Enables Jest functions to be run within Zone.js context", "main": "index.js", "repository": "git@github.com:thymikee/jest-zone-patch.git", From d3475135936c8b0a1a6942155d9ece313dfb57ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 28 Mar 2017 21:16:14 +0200 Subject: [PATCH 09/23] Add .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..722d5e71d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode From d04cced27f6e7ffa9b81da657a23d2bd05869e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 28 Mar 2017 21:23:35 +0200 Subject: [PATCH 10/23] v0.0.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 310d5ceb47..7ce937517e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jest-zone-patch", - "version": "0.0.4", + "version": "0.0.5", "description": "Enables Jest functions to be run within Zone.js context", "main": "index.js", "repository": "git@github.com:thymikee/jest-zone-patch.git", From b7b583856295ca513d3b7163cf1fb11366e811ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Sat, 1 Apr 2017 15:53:00 +0200 Subject: [PATCH 11/23] Wrap ifs in curly brackets --- index.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 97b10e050b..56133f21e3 100644 --- a/index.js +++ b/index.js @@ -3,24 +3,30 @@ * always runs in a testZone (ProxyZone). */ -if (Zone === undefined) throw new Error('Missing: Zone (zone.js)'); -if (jest === undefined) +if (Zone === undefined) { + throw new Error('Missing: Zone (zone.js)'); +} +if (jest === undefined) { throw new Error( 'Missing: jest.\n' + 'This patch must be included in a script called with ' + '`setupTestFrameworkScriptFile` in Jest config.' ); -if (jest['__zone_patch__'] === true) +} +if (jest['__zone_patch__'] === true) { throw new Error("'jest' has already been patched with 'Zone'."); +} jest['__zone_patch__'] = true; const SyncTestZoneSpec = Zone['SyncTestZoneSpec']; const ProxyZoneSpec = Zone['ProxyZoneSpec']; -if (SyncTestZoneSpec === undefined) +if (SyncTestZoneSpec === undefined) { throw new Error('Missing: SyncTestZoneSpec (zone.js/dist/sync-test)'); -if (ProxyZoneSpec === undefined) +} +if (ProxyZoneSpec === undefined) { throw new Error('Missing: ProxyZoneSpec (zone.js/dist/proxy.js)'); +} const env = global; const ambientZone = Zone.current; From 2972987b778a92fd2fab4206c21f34603ae8454a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 12 Apr 2017 22:54:50 +0200 Subject: [PATCH 12/23] Add zone.js as peerDep --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ce937517e..44328f265a 100644 --- a/package.json +++ b/package.json @@ -5,5 +5,8 @@ "main": "index.js", "repository": "git@github.com:thymikee/jest-zone-patch.git", "author": "Michał Pierzchała ", - "license": "BSD-3" + "license": "BSD-3", + "peerDependencies": { + "zone.js": "^0.7.5" + } } From e99bb6e87894fa016bd1fa2cd7634c7de9d61a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 12 Apr 2017 22:57:55 +0200 Subject: [PATCH 13/23] Ignore node_modules --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 722d5e71d9..7c787426b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .vscode +node_modules From caf977ae132b02609b831ae3b8978b67a66c4935 Mon Sep 17 00:00:00 2001 From: Andreas Krummsdorf Date: Thu, 11 May 2017 11:42:50 +0200 Subject: [PATCH 14/23] Bump zone.js peerDependency, use a valid SPDX license expression (#4) --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 44328f265a..4adc544802 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "main": "index.js", "repository": "git@github.com:thymikee/jest-zone-patch.git", "author": "Michał Pierzchała ", - "license": "BSD-3", + "license": "BSD-3-Clause", "peerDependencies": { - "zone.js": "^0.7.5" + "zone.js": ">=0.7.5" } } From f4cfb558f325ed42efa7f8829cf2b5841b785456 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 26 Sep 2017 02:57:03 -0400 Subject: [PATCH 15/23] fix: allow empty test bodies (#5) --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 56133f21e3..9e2eb1af5a 100644 --- a/index.js +++ b/index.js @@ -43,6 +43,9 @@ function wrapDescribeInZone(describeBody) { // can retroactively install different zones. const testProxyZone = ambientZone.fork(new ProxyZoneSpec()); function wrapTestInZone(testBody) { + if (testBody === undefined) { + return; + } return testBody.length === 0 ? () => testProxyZone.run(testBody, null) : done => testProxyZone.run(testBody, null, [done]); From a81ee424c9cadc2dca1dccecc2345dbd0252ee10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 12 Apr 2017 22:58:50 +0200 Subject: [PATCH 16/23] v0.0.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4adc544802..ed2a5c9262 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jest-zone-patch", - "version": "0.0.5", + "version": "0.0.6", "description": "Enables Jest functions to be run within Zone.js context", "main": "index.js", "repository": "git@github.com:thymikee/jest-zone-patch.git", From 457631ee109b961d06396e6e6ca168619144fa30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 11 May 2017 12:29:46 +0200 Subject: [PATCH 17/23] v0.0.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ed2a5c9262..10d941d696 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jest-zone-patch", - "version": "0.0.6", + "version": "0.0.7", "description": "Enables Jest functions to be run within Zone.js context", "main": "index.js", "repository": "git@github.com:thymikee/jest-zone-patch.git", From b89a5a57bdcd272aae3386d78a871dd0aac292fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 26 Sep 2017 13:56:14 +0200 Subject: [PATCH 18/23] v0.0.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 10d941d696..28c545f69b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jest-zone-patch", - "version": "0.0.7", + "version": "0.0.8", "description": "Enables Jest functions to be run within Zone.js context", "main": "index.js", "repository": "git@github.com:thymikee/jest-zone-patch.git", From 72ec465fdc9b89c8753a53ef15bd2903aa43807f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Wed, 5 Dec 2018 18:18:12 +0800 Subject: [PATCH 19/23] feat: support jest-each method (#8) * feat: support jest-each method * feat: support fdescribe.each and xdescribe.each * feat: support xtest and xtest.each * fix: align signature with jest * fix: pass through `describe` arguments --- index.js | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 9e2eb1af5a..96e9002353 100644 --- a/index.js +++ b/index.js @@ -51,30 +51,49 @@ function wrapTestInZone(testBody) { : done => testProxyZone.run(testBody, null, [done]); } +const bindDescribe = (originalJestFn) => function () { + const eachArguments = arguments; + return function (description, specDefinitions, timeout) { + arguments[1] = wrapDescribeInZone(specDefinitions) + return originalJestFn.apply(this, eachArguments).apply( + this, + arguments + ) + } +}; + ['xdescribe', 'fdescribe', 'describe'].forEach(methodName => { const originaljestFn = env[methodName]; - env[methodName] = function(description, specDefinitions) { - return originaljestFn.call( + env[methodName] = function(description, specDefinitions, timeout) { + arguments[1] = wrapDescribeInZone(specDefinitions) + return originaljestFn.apply( this, - description, - wrapDescribeInZone(specDefinitions) + arguments ); }; + env[methodName].each = bindDescribe(originaljestFn.each); if (methodName === 'describe') { env[methodName].only = env['fdescribe']; env[methodName].skip = env['xdescribe']; + env[methodName].only.each = bindDescribe(originaljestFn.only.each); + env[methodName].skip.each = bindDescribe(originaljestFn.skip.each); } }); -['xit', 'fit', 'test', 'it'].forEach(methodName => { +['xit', 'fit', 'xtest', 'test', 'it'].forEach(methodName => { const originaljestFn = env[methodName]; env[methodName] = function(description, specDefinitions, timeout) { arguments[1] = wrapTestInZone(specDefinitions); return originaljestFn.apply(this, arguments); }; + // The revised method will be populated to the final each method, so we only declare the method that in the new globals + env[methodName].each = originaljestFn.each; if (methodName === 'test' || methodName === 'it') { env[methodName].only = env['fit']; + env[methodName].only.each = originaljestFn.only.each; + env[methodName].skip = env['xit']; + env[methodName].skip.each = originaljestFn.skip.each; } }); From 3c8aa04279c9c9de1edc75b4e0665c7a282ce3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 5 Dec 2018 11:19:14 +0100 Subject: [PATCH 20/23] v0.0.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 28c545f69b..8812402d98 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jest-zone-patch", - "version": "0.0.8", + "version": "0.0.9", "description": "Enables Jest functions to be run within Zone.js context", "main": "index.js", "repository": "git@github.com:thymikee/jest-zone-patch.git", From 446607374e3f8b4fd67006630aa2f7c41d47c7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Mon, 10 Dec 2018 18:50:03 +0800 Subject: [PATCH 21/23] fix: improper bindings of arguments (#9) --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 96e9002353..905ab6906f 100644 --- a/index.js +++ b/index.js @@ -36,7 +36,7 @@ const ambientZone = Zone.current; // inside of a `describe` but outside of a `beforeEach` or `it`. const syncZone = ambientZone.fork(new SyncTestZoneSpec('jest.describe')); function wrapDescribeInZone(describeBody) { - return () => syncZone.run(describeBody, null, arguments); + return function () { return syncZone.run(describeBody, null, arguments); } } // Create a proxy zone in which to run `test` blocks so that the tests function From 562be0a57a92d16ce22e0243d93f715e938f6634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 10 Dec 2018 11:51:09 +0100 Subject: [PATCH 22/23] v0.0.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8812402d98..bba6688e7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jest-zone-patch", - "version": "0.0.9", + "version": "0.0.10", "description": "Enables Jest functions to be run within Zone.js context", "main": "index.js", "repository": "git@github.com:thymikee/jest-zone-patch.git", From 8acde824dc1f5b238434f854ecad8adf37ec361d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hua=CC=81ng=20Ju=CC=80nlia=CC=80ng?= Date: Thu, 13 Dec 2018 20:54:42 +0800 Subject: [PATCH 23/23] refactor: cleanup jest-zone-patch reference --- package.json | 1 - setupJest.js | 2 +- zone-patch/.gitignore | 2 -- zone-patch/README.md | 19 +++---------------- zone-patch/package.json | 12 ------------ 5 files changed, 4 insertions(+), 32 deletions(-) delete mode 100644 zone-patch/.gitignore delete mode 100644 zone-patch/package.json diff --git a/package.json b/package.json index e6e2fb87f8..90800db957 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "license": "MIT", "dependencies": { "@types/jest": "^23.3.10", - "jest-zone-patch": ">=0.0.9 <1.0.0", "ts-jest": "~23.10.0" }, "devDependencies": { diff --git a/setupJest.js b/setupJest.js index 2f89f19dc5..f71d5194e7 100644 --- a/setupJest.js +++ b/setupJest.js @@ -7,7 +7,7 @@ require('zone.js/dist/proxy.js'); require('zone.js/dist/sync-test'); require('zone.js/dist/async-test'); require('zone.js/dist/fake-async-test'); -require('jest-zone-patch'); +require('./zone-patch'); const getTestBed = require('@angular/core/testing').getTestBed; const BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing').BrowserDynamicTestingModule; diff --git a/zone-patch/.gitignore b/zone-patch/.gitignore deleted file mode 100644 index 7c787426b6..0000000000 --- a/zone-patch/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.vscode -node_modules diff --git a/zone-patch/README.md b/zone-patch/README.md index bc5f168d08..55a8fa7eec 100644 --- a/zone-patch/README.md +++ b/zone-patch/README.md @@ -1,19 +1,6 @@ -# jest-zone-patch +# zone-patch Enables Jest functions to be run within Zone.js context, specifically for [Angular](https://angular.io) apps. -## Usage - -Place it in your `setupJestTestFramework.ts` (or so) file -```js -import 'jest-zone-patch'; -``` - -And run it as Jest's `setupTestFrameworkScriptFile`: - -```json -"jest": { - "setupTestFrameworkScriptFile": "/src/setupJestTestFramework.ts" -} -``` - It's crucial to run this patch here, because at this point patched functions like `test` or `describe` are available in global scope. + +`zone-patch` has been included in `setupJest.js` by default. diff --git a/zone-patch/package.json b/zone-patch/package.json deleted file mode 100644 index bba6688e7b..0000000000 --- a/zone-patch/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "jest-zone-patch", - "version": "0.0.10", - "description": "Enables Jest functions to be run within Zone.js context", - "main": "index.js", - "repository": "git@github.com:thymikee/jest-zone-patch.git", - "author": "Michał Pierzchała ", - "license": "BSD-3-Clause", - "peerDependencies": { - "zone.js": ">=0.7.5" - } -}