Skip to content

Commit

Permalink
test: top level await esbuild compatibility (vitejs#3944)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored and aleclarson committed Nov 8, 2021
1 parent 5017aeb commit 877c2cd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/playground/vue/AsyncComponent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<h2>Async Component</h2>
<p>Testing TLA and for await compatibility with esbuild</p>
<p class="async-component">ab == {{ test }}</p>
</template>

<script setup lang="ts">
let test = ''
const forAwaitTest = async (array): Promise<void> => {
for await (const value of array) {
test += value
}
}
await forAwaitTest([Promise.resolve('a'), Promise.resolve('b')]).catch(() => { })
</script>
4 changes: 4 additions & 0 deletions packages/playground/vue/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<div class="slotted">this should be red</div>
</Slotted>
<ScanDep />
<Suspense>
<AsyncComponent />
</Suspense>
</template>

<script setup lang="ts">
Expand All @@ -27,6 +30,7 @@ import CustomBlock from './CustomBlock.vue'
import SrcImport from './src-import/SrcImport.vue'
import Slotted from './Slotted.vue'
import ScanDep from './ScanDep.vue'
import AsyncComponent from './AsyncComponent.vue'
import { ref } from 'vue'
Expand Down
6 changes: 6 additions & 0 deletions packages/playground/vue/__tests__/vue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,9 @@ describe('custom blocks', () => {
expect(await page.textContent('.custom-block')).toMatch('こんにちは')
})
})

describe('async component', () => {
test('should work', async () => {
expect(await page.textContent('.async-component')).toMatch('ab == ab')
})
})

0 comments on commit 877c2cd

Please sign in to comment.