From 533a010b2859f0cf56c066e7960340cf11ac59ab Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sun, 17 Dec 2017 22:18:50 -0800 Subject: [PATCH] build(platform-browser): exclude node incompatible tests from :test target. (#21053) PR Close #21053 --- .../test/animation/animation_renderer_spec.ts | 5 +++-- .../test/animation/browser_animation_builder_spec.ts | 1 + packages/platform-browser/test/browser/bootstrap_spec.ts | 1 + .../platform-browser/test/browser/browser_adapter_spec.ts | 1 + packages/platform-browser/test/browser/tools/tools_spec.ts | 1 + packages/platform-browser/test/dom/dom_renderer_spec.ts | 1 + .../platform-browser/test/dom/events/event_manager_spec.ts | 5 +++-- .../platform-browser/test/dom/events/hammer_gestures_spec.ts | 1 + packages/platform-browser/test/dom/events/key_events_spec.ts | 1 + packages/service-worker/worker/testing/scope.ts | 3 ++- 10 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/platform-browser/test/animation/animation_renderer_spec.ts b/packages/platform-browser/test/animation/animation_renderer_spec.ts index 39e47a42ae..05a0c0d8e9 100644 --- a/packages/platform-browser/test/animation/animation_renderer_spec.ts +++ b/packages/platform-browser/test/animation/animation_renderer_spec.ts @@ -14,7 +14,8 @@ import {DomRendererFactory2} from '@angular/platform-browser/src/dom/dom_rendere import {InjectableAnimationEngine} from '../../animations/src/providers'; import {el} from '../../testing/src/browser_util'; -{ +(function() { + if (isNode) return; describe('AnimationRenderer', () => { let element: any; beforeEach(() => { @@ -307,7 +308,7 @@ import {el} from '../../testing/src/browser_util'; expect(renderer.log).toEqual(['begin', 'end']); }); }); -} +})(); @Injectable() class MockAnimationEngine extends InjectableAnimationEngine { diff --git a/packages/platform-browser/test/animation/browser_animation_builder_spec.ts b/packages/platform-browser/test/animation/browser_animation_builder_spec.ts index 012b130fe6..66202e035e 100644 --- a/packages/platform-browser/test/animation/browser_animation_builder_spec.ts +++ b/packages/platform-browser/test/animation/browser_animation_builder_spec.ts @@ -17,6 +17,7 @@ import {el} from '../../testing/src/browser_util'; { describe('BrowserAnimationBuilder', () => { + if (isNode) return; let element: any; beforeEach(() => { element = el('
'); diff --git a/packages/platform-browser/test/browser/bootstrap_spec.ts b/packages/platform-browser/test/browser/bootstrap_spec.ts index 947ef60773..f6e86df934 100644 --- a/packages/platform-browser/test/browser/bootstrap_spec.ts +++ b/packages/platform-browser/test/browser/bootstrap_spec.ts @@ -132,6 +132,7 @@ function bootstrap( lightDom: any /** TODO #9100 */; describe('bootstrap factory method', () => { + if (isNode) return; let compilerConsole: DummyConsole; beforeEachProviders(() => { return [Log]; }); diff --git a/packages/platform-browser/test/browser/browser_adapter_spec.ts b/packages/platform-browser/test/browser/browser_adapter_spec.ts index f73b8bc90c..77538fd766 100644 --- a/packages/platform-browser/test/browser/browser_adapter_spec.ts +++ b/packages/platform-browser/test/browser/browser_adapter_spec.ts @@ -12,6 +12,7 @@ import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; { describe('cookies', () => { + if (isNode) return; it('sets cookie values', () => { getDOM().setCookie('my test cookie', 'my test value'); getDOM().setCookie('my other cookie', 'my test value 2'); diff --git a/packages/platform-browser/test/browser/tools/tools_spec.ts b/packages/platform-browser/test/browser/tools/tools_spec.ts index 9985125712..e66f217d45 100644 --- a/packages/platform-browser/test/browser/tools/tools_spec.ts +++ b/packages/platform-browser/test/browser/tools/tools_spec.ts @@ -12,6 +12,7 @@ import {SpyComponentRef, callNgProfilerTimeChangeDetection} from './spies'; { describe('profiler', () => { + if (isNode) return; beforeEach(() => { enableDebugTools((new SpyComponentRef())); }); afterEach(() => { disableDebugTools(); }); diff --git a/packages/platform-browser/test/dom/dom_renderer_spec.ts b/packages/platform-browser/test/dom/dom_renderer_spec.ts index 1b4ca221f6..1386e8b617 100644 --- a/packages/platform-browser/test/dom/dom_renderer_spec.ts +++ b/packages/platform-browser/test/dom/dom_renderer_spec.ts @@ -14,6 +14,7 @@ import {NAMESPACE_URIS} from '../../src/dom/dom_renderer'; { describe('DefaultDomRendererV2', () => { + if (isNode) return; let renderer: Renderer2; beforeEach(() => { diff --git a/packages/platform-browser/test/dom/events/event_manager_spec.ts b/packages/platform-browser/test/dom/events/event_manager_spec.ts index 8597d1a8a6..5f67243643 100644 --- a/packages/platform-browser/test/dom/events/event_manager_spec.ts +++ b/packages/platform-browser/test/dom/events/event_manager_spec.ts @@ -13,7 +13,8 @@ import {DomEventsPlugin} from '@angular/platform-browser/src/dom/events/dom_even import {EventManager, EventManagerPlugin} from '@angular/platform-browser/src/dom/events/event_manager'; import {el} from '../../../testing/src/browser_util'; -{ +(function() { + if (isNode) return; let domEventPlugin: DomEventsPlugin; let doc: any; let zone: NgZone; @@ -319,7 +320,7 @@ import {el} from '../../../testing/src/browser_util'; expect(receivedEvent).toBe(null); }); }); -} +})(); /** @internal */ class FakeEventManagerPlugin extends EventManagerPlugin { diff --git a/packages/platform-browser/test/dom/events/hammer_gestures_spec.ts b/packages/platform-browser/test/dom/events/hammer_gestures_spec.ts index 40bc6f8187..549161065c 100644 --- a/packages/platform-browser/test/dom/events/hammer_gestures_spec.ts +++ b/packages/platform-browser/test/dom/events/hammer_gestures_spec.ts @@ -10,6 +10,7 @@ import {HammerGestureConfig, HammerGesturesPlugin} from '@angular/platform-brows { describe('HammerGesturesPlugin', () => { + if (isNode) return; it('should implement addGlobalEventListener', () => { const plugin = new HammerGesturesPlugin(document, new HammerGestureConfig()); diff --git a/packages/platform-browser/test/dom/events/key_events_spec.ts b/packages/platform-browser/test/dom/events/key_events_spec.ts index 9cbeb2cf73..648852de64 100644 --- a/packages/platform-browser/test/dom/events/key_events_spec.ts +++ b/packages/platform-browser/test/dom/events/key_events_spec.ts @@ -11,6 +11,7 @@ import {KeyEventsPlugin} from '@angular/platform-browser/src/dom/events/key_even { describe('KeyEventsPlugin', () => { + if (isNode) return; it('should ignore unrecognized events', () => { expect(KeyEventsPlugin.parseEventName('keydown')).toEqual(null); diff --git a/packages/service-worker/worker/testing/scope.ts b/packages/service-worker/worker/testing/scope.ts index c918e335d7..f87fa0f6af 100644 --- a/packages/service-worker/worker/testing/scope.ts +++ b/packages/service-worker/worker/testing/scope.ts @@ -96,7 +96,8 @@ export class SwTestHarness implements ServiceWorkerGlobalScope, Adapter, Context } as any; static envIsSupported(): boolean { - return (typeof URL === 'function') || (typeof require === 'function' && typeof require('url')['parse'] === 'function'); + return (typeof URL === 'function') || + (typeof require === 'function' && typeof require('url')['parse'] === 'function'); } time: number;