@@ -185,6 +185,8 @@ test("anomaly detection", () => {
185185
186186 const scope = new TestMonitoringScope ( stack , "Scope" ) ;
187187
188+ let numAlarmsCreated = 0 ;
189+
188190 new CustomMonitoring ( scope , {
189191 alarmFriendlyName : "AnomalyAlarmName" ,
190192 metricGroups : [
@@ -215,15 +217,24 @@ test("anomaly detection", () => {
215217 ] ,
216218 } ,
217219 ] ,
220+ useCreatedAlarms : {
221+ consume ( alarms ) {
222+ numAlarmsCreated = alarms . length ;
223+ } ,
224+ } ,
218225 } ) ;
219226
227+ expect ( numAlarmsCreated ) . toStrictEqual ( 1 ) ;
228+
220229 expect ( Template . fromStack ( stack ) ) . toMatchSnapshot ( ) ;
221230} ) ;
222231
223232test ( "enhanced anomaly detection" , ( ) => {
224233 const stack = new Stack ( ) ;
225234 const scope = new TestMonitoringScope ( stack , "Scope" ) ;
226235
236+ let numAlarmsCreated = 0 ;
237+
227238 new CustomMonitoring ( scope , {
228239 alarmFriendlyName : "AnomalyAlarmName" ,
229240 metricGroups : [
@@ -271,15 +282,24 @@ test("enhanced anomaly detection", () => {
271282 ] ,
272283 } ,
273284 ] ,
285+ useCreatedAlarms : {
286+ consume ( alarms ) {
287+ numAlarmsCreated = alarms . length ;
288+ } ,
289+ } ,
274290 } ) ;
275291
292+ expect ( numAlarmsCreated ) . toStrictEqual ( 3 ) ;
293+
276294 expect ( Template . fromStack ( stack ) ) . toMatchSnapshot ( ) ;
277295} ) ;
278296
279297test ( "enhanced anomaly detection with more complex metric" , ( ) => {
280298 const stack = new Stack ( ) ;
281299 const scope = new TestMonitoringScope ( stack , "Scope" ) ;
282300
301+ let numAlarmsCreated = 0 ;
302+
283303 new CustomMonitoring ( scope , {
284304 alarmFriendlyName : "AnomalyAlarmName" ,
285305 metricGroups : [
@@ -307,15 +327,24 @@ test("enhanced anomaly detection with more complex metric", () => {
307327 ] ,
308328 } ,
309329 ] ,
330+ useCreatedAlarms : {
331+ consume ( alarms ) {
332+ numAlarmsCreated = alarms . length ;
333+ } ,
334+ } ,
310335 } ) ;
311336
337+ expect ( numAlarmsCreated ) . toStrictEqual ( 1 ) ;
338+
312339 expect ( Template . fromStack ( stack ) ) . toMatchSnapshot ( ) ;
313340} ) ;
314341
315342test ( "enhanced anomaly detection with metric math" , ( ) => {
316343 const stack = new Stack ( ) ;
317344 const scope = new TestMonitoringScope ( stack , "Scope" ) ;
318345
346+ let numAlarmsCreated = 0 ;
347+
319348 const m1 = new Metric ( {
320349 metricName : "Metric1" ,
321350 namespace : "AnomalyNamespace" ,
@@ -349,8 +378,15 @@ test("enhanced anomaly detection with metric math", () => {
349378 ] ,
350379 } ,
351380 ] ,
381+ useCreatedAlarms : {
382+ consume ( alarms ) {
383+ numAlarmsCreated = alarms . length ;
384+ } ,
385+ } ,
352386 } ) ;
353387
388+ expect ( numAlarmsCreated ) . toStrictEqual ( 1 ) ;
389+
354390 expect ( Template . fromStack ( stack ) ) . toMatchSnapshot ( ) ;
355391} ) ;
356392
0 commit comments