@@ -4,7 +4,7 @@ import { CoreAnalytics } from '../../analytics'
44import { pWhile } from '../../utils/p-while'
55import * as timer from '../../priority-queue/backoff'
66import { ContextCancelation } from '../../context'
7- import { CorePlugin } from '../../plugins'
7+ import { CorePlugin , PluginType } from '../../plugins'
88import { pTimeout } from '../../callback'
99import { TestCtx , TestEventQueue } from '../../../test-helpers'
1010
@@ -609,6 +609,32 @@ describe('Flushing', () => {
609609 } )
610610} )
611611
612+ describe ( 'register' , ( ) => {
613+ it ( 'only filters out failed destinations after loading' , async ( ) => {
614+ const eq = new TestEventQueue ( )
615+ const goodDestinationPlugin = {
616+ ...testPlugin ,
617+ name : 'good destination' ,
618+ type : 'destination' as PluginType ,
619+ }
620+ const failingPlugin = {
621+ ...testPlugin ,
622+ name : 'failing' ,
623+ type : 'destination' as PluginType ,
624+
625+ load : ( ) => Promise . reject ( new Error ( 'I was born to throw' ) ) ,
626+ }
627+
628+ const plugins = [ testPlugin , goodDestinationPlugin , failingPlugin ]
629+ const promises = plugins . map ( ( p ) => eq . register ( TestCtx . system ( ) , p , ajs ) )
630+ await Promise . all ( promises )
631+
632+ expect ( eq . plugins . length ) . toBe ( 2 )
633+ expect ( eq . plugins ) . toContain ( testPlugin )
634+ expect ( eq . plugins ) . toContain ( goodDestinationPlugin )
635+ } )
636+ } )
637+
612638describe ( 'deregister' , ( ) => {
613639 it ( 'remove plugin from plugins list' , async ( ) => {
614640 const eq = new TestEventQueue ( )
0 commit comments