15
15
* limitations under the License.
16
16
*/
17
17
18
+ import 'reflect-metadata/Reflect' ;
19
+ import 'zone.js/dist/zone' ;
20
+ import 'zone.js/dist/webapis-shadydom' ; // https://github.com/angular/zone.js/pull/784
21
+ import 'zone.js/dist/long-stack-trace-zone' ;
22
+ import 'zone.js/dist/proxy' ;
23
+ import 'zone.js/dist/sync-test' ;
24
+ import 'zone.js/dist/mocha-patch' ;
25
+ import 'zone.js/dist/async-test' ;
26
+ import 'zone.js/dist/fake-async-test' ;
27
+ import { getTestBed } from '@angular/core/testing' ;
28
+ import {
29
+ BrowserDynamicTestingModule ,
30
+ platformBrowserDynamicTesting
31
+ } from '@angular/platform-browser-dynamic/testing' ;
18
32
import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core" ;
19
- import { TestBed } from "@angular/core/testing" ;
20
-
21
33
import {
22
- ComponentWithoutChildren ,
23
34
ComponentWithChildren ,
24
- ComponentWithChildrenRerender ,
25
- ComponentWithDifferentViews ,
26
- ComponentWithProperties ,
27
- ComponentWithUnregistered ,
28
- ComponentWithImperativeEvent ,
29
- ComponentWithDeclarativeEvent
30
- } from "./components" ;
35
+ ComponentWithChildrenRerender , ComponentWithDeclarativeEvent ,
36
+ ComponentWithDifferentViews , ComponentWithImperativeEvent ,
37
+ ComponentWithoutChildren , ComponentWithProperties , ComponentWithUnregistered
38
+ } from "./src/components" ;
39
+
40
+ import basicTests from "basic-tests" ;
41
+ import advancedTests from "advanced-tests" ;
42
+
43
+
44
+ // Prevent Karma from running prematurely.
45
+ __karma__ . loaded = function ( ) { } ;
46
+
47
+ // First, initialize the Angular testing environment.
48
+ getTestBed ( ) . initTestEnvironment (
49
+ BrowserDynamicTestingModule ,
50
+ platformBrowserDynamicTesting ( )
51
+ ) ;
52
+ // Run basic and advanced tests through Karma
31
53
32
- import tests from 'basic-tests' ;
33
54
34
55
beforeEach ( function ( ) {
35
- TestBed . configureTestingModule ( {
56
+ getTestBed ( ) . configureTestingModule ( {
36
57
declarations : [
37
58
ComponentWithoutChildren ,
38
59
ComponentWithChildren ,
@@ -48,14 +69,14 @@ beforeEach(function() {
48
69
} ) ;
49
70
50
71
function render ( Component ) {
51
- const fixture = TestBed . createComponent ( Component ) ;
72
+ const fixture = getTestBed ( ) . createComponent ( Component ) ;
52
73
fixture . detectChanges ( ) ;
53
74
const el = fixture . debugElement . nativeElement ;
54
75
const wc = el . querySelector ( '#wc' ) ;
55
76
return { wc, fixture }
56
77
}
57
78
58
- tests ( {
79
+ const renderers = {
59
80
renderComponentWithoutChildren ( ) {
60
81
return render ( ComponentWithoutChildren ) ;
61
82
} ,
@@ -86,5 +107,19 @@ tests({
86
107
fixture . detectChanges ( ) ;
87
108
}
88
109
return { wc, fixture, click } ;
110
+ } ,
111
+ renderComponentWithDeclarativeEvent ( ) {
112
+ const { wc, fixture } = render ( ComponentWithDeclarativeEvent ) ;
113
+ function click ( ) {
114
+ wc . click ( ) ;
115
+ fixture . detectChanges ( ) ;
116
+ }
117
+ return { wc, fixture, click } ;
89
118
}
90
- } ) ;
119
+ } ;
120
+
121
+ basicTests ( renderers ) ;
122
+ advancedTests ( renderers ) ;
123
+
124
+ // Finally, start Karma to run the tests.
125
+ __karma__ . start ( ) ;
0 commit comments