@@ -9,7 +9,7 @@ import { schema } from '@angular-devkit/core';
9
9
import { timer } from 'rxjs' ;
10
10
import { map , take , tap , toArray } from 'rxjs/operators' ;
11
11
import { TestingArchitectHost } from '../testing/testing-architect-host' ;
12
- import { BuilderOutput } from './api' ;
12
+ import { BuilderOutput , BuilderRun } from './api' ;
13
13
import { Architect } from './architect' ;
14
14
import { createBuilder } from './create-builder' ;
15
15
@@ -135,4 +135,54 @@ describe('architect', () => {
135
135
expect ( results ) . toBe ( 10 ) ;
136
136
expect ( all . length ) . toBe ( 10 ) ;
137
137
} ) ;
138
+
139
+ it ( 'reports errors in the builder' , async ( ) => {
140
+ testArchitectHost . addBuilder ( 'package:error' , createBuilder ( ( ) => {
141
+ throw new Error ( 'Error in the builder.' ) ;
142
+ } ) ) ;
143
+
144
+ let run : BuilderRun | undefined = undefined ;
145
+ try {
146
+ try {
147
+ // This should not throw.
148
+ run = await architect . scheduleBuilder ( 'package:error' , { } ) ;
149
+ } catch ( err ) {
150
+ expect ( err ) . toBeUndefined ( ) ;
151
+ throw err ;
152
+ }
153
+
154
+ // This should throw.
155
+ await run . result ;
156
+ expect ( 'to throw' ) . not . toEqual ( 'to throw' ) ;
157
+ } catch {
158
+ }
159
+ if ( run ) {
160
+ await run . stop ( ) ;
161
+ }
162
+ } ) ;
163
+
164
+ it ( 'reports errors in the builder (async)' , async ( ) => {
165
+ testArchitectHost . addBuilder ( 'package:error' , createBuilder ( ( ) => {
166
+ return new Promise ( ( _ , reject ) => reject ( new Error ( 'Error async' ) ) ) ;
167
+ } ) ) ;
168
+
169
+ let run : BuilderRun | undefined = undefined ;
170
+ try {
171
+ try {
172
+ // This should not throw.
173
+ run = await architect . scheduleBuilder ( 'package:error' , { } ) ;
174
+ } catch ( err ) {
175
+ expect ( err ) . toBeUndefined ( ) ;
176
+ throw err ;
177
+ }
178
+
179
+ // This should throw.
180
+ await run . result ;
181
+ expect ( 'to throw' ) . not . toEqual ( 'to throw' ) ;
182
+ } catch {
183
+ }
184
+ if ( run ) {
185
+ await run . stop ( ) ;
186
+ }
187
+ } ) ;
138
188
} ) ;
0 commit comments