File tree Expand file tree Collapse file tree 3 files changed +8
-11
lines changed
packages/core/src/test/shared Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import * as SamUtilsModule from '../../../../shared/sam/utils'
1212import * as ButtonsModule from '../../../../shared/ui/buttons'
1313import { createEcrPrompter } from '../../../../shared/ui/sam/ecrPrompter'
1414import { intoCollection } from '../../../../shared/utilities/collectionUtils'
15+ import { sleep } from '../../../../shared/utilities/timeoutUtils'
1516
1617describe ( 'createEcrPrompter' , ( ) => {
1718 let sandbox : sinon . SinonSandbox
@@ -76,7 +77,7 @@ describe('createEcrPrompter', () => {
7677
7778 // Act
7879 const prompter = createEcrPrompter ( ecrClient , mementoRootKey )
79- await new Promise ( ( f ) => setTimeout ( f , 50 ) )
80+ await sleep ( 50 )
8081
8182 // Assert
8283 assert . ok ( createCommonButtonsStub . calledOnce )
@@ -103,7 +104,7 @@ describe('createEcrPrompter', () => {
103104
104105 // Act
105106 const prompter = createEcrPrompter ( ecrClient , mementoRootKey )
106- await new Promise ( ( f ) => setTimeout ( f , 50 ) )
107+ await sleep ( 50 )
107108
108109 // Assert
109110 assert . ok ( createCommonButtonsStub . calledOnce )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { DefaultCloudFormationClient } from '../../../../shared/clients/cloudFor
1414import { samSyncUrl } from '../../../../shared/constants'
1515import { createStackPrompter } from '../../../../shared/ui/sam/stackPrompter'
1616import { intoCollection } from '../../../../shared/utilities/collectionUtils'
17+ import { sleep } from '../../../../shared/utilities/timeoutUtils'
1718
1819describe ( 'createStackPrompter' , ( ) => {
1920 let sandbox : sinon . SinonSandbox
@@ -81,7 +82,7 @@ describe('createStackPrompter', () => {
8182
8283 // Act
8384 const prompter = createStackPrompter ( cfnClient , mementoRootKey , samSyncUrl )
84- await new Promise ( ( f ) => setTimeout ( f , 50 ) )
85+ await sleep ( 50 )
8586
8687 // Assert
8788 assert . ok ( createCommonButtonsStub . calledOnce )
@@ -108,7 +109,7 @@ describe('createStackPrompter', () => {
108109
109110 // Act
110111 const prompter = createStackPrompter ( cfnClient , mementoRootKey , samSyncUrl )
111- await new Promise ( ( f ) => setTimeout ( f , 50 ) )
112+ await sleep ( 50 )
112113
113114 // Assert
114115 assert . ok ( createCommonButtonsStub . calledOnce )
Original file line number Diff line number Diff line change 66import assert from 'assert'
77import { TestInputBox , TestQuickPick } from '../vscode/quickInput'
88import { getTestWindow , TestWindow } from '../vscode/window'
9+ import { waitUntil } from '../../../shared/utilities/timeoutUtils'
910
1011interface PrompterTesterConfig {
1112 testWindow ?: TestWindow
@@ -111,13 +112,7 @@ export class PrompterTester {
111112 }
112113
113114 try {
114- const timeoutPromise = new Promise < never > ( ( _ , reject ) => {
115- setTimeout ( ( ) => {
116- reject ( new Error ( `Handler for "${ input . title } " exceeded ${ this . handlerTimout } ms timeout` ) )
117- } , this . handlerTimout )
118- } )
119-
120- await Promise . race ( [ handler ( input ) , timeoutPromise ] )
115+ await waitUntil ( handler ( input ) , { timeout : this . handlerTimout , interval : 50 } )
121116 } catch ( e ) {
122117 // clean up UI on callback function early exit (e.g assertion failure)
123118 await input . dispose ( )
You can’t perform that action at this time.
0 commit comments