Skip to content

Commit

Permalink
fix: wait for page reload
Browse files Browse the repository at this point in the history
  • Loading branch information
poyoho committed Apr 23, 2022
1 parent 9ebbc0a commit 683d436
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/playground/assets/__tests__/assets.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createHash } from 'crypto'
import {
findAssetFile,
getBg,
Expand All @@ -9,7 +8,8 @@ import {
readFile,
editFile,
notifyRebuildComplete,
untilUpdated
untilUpdated,
timeout
} from '../../testUtils'

const assetMatch = isBuild
Expand Down Expand Up @@ -304,6 +304,8 @@ if (!isBuild) {
(code) => code.replace('#0088ff', '#00ff88'),
true
)
// wait for page reload
await timeout(200)
await untilUpdated(() => getColor('.import-css'), 'rgb(0, 255, 136)')
})
}
Expand Down
4 changes: 2 additions & 2 deletions packages/playground/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function rgbToHex(rgb: string): string {
}
}

const timeout = (n: number) => new Promise((r) => setTimeout(r, n))
export const timeout = (n: number) => new Promise((r) => setTimeout(r, n))

async function toEl(el: string | ElementHandle): Promise<ElementHandle> {
if (typeof el === 'string') {
Expand Down Expand Up @@ -148,7 +148,7 @@ export async function untilUpdated(
expect(actual).toMatch(expected)
break
} else {
await timeout(100)
await timeout(50)
}
}
}
Expand Down

0 comments on commit 683d436

Please sign in to comment.