Skip to content

Commit c1ce8d7

Browse files
committed
Add reproduction
1 parent 0650a9a commit c1ce8d7

File tree

7 files changed

+1139
-1
lines changed

7 files changed

+1139
-1
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
yarn-error.log

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# vue-compat-composition-api-bug-repo
1+
# vue-compat-composition-api-bug-repo
2+
3+
Reproduction for @vue/compat mode issue with composition API.
4+
5+
`yarn test:vue3`
6+
7+
`yarn test:vue-compat`

package.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "vue-compat-composition-api-bug-repo",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test:vue3": "vitest run",
8+
"test:vue-compat": "vitest run --config vite.config.compat.js"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/Weetbix/vue-compat-composition-api-bug-repo.git"
13+
},
14+
"author": "",
15+
"license": "MIT",
16+
"bugs": {
17+
"url": "https://github.com/Weetbix/vue-compat-composition-api-bug-repo/issues"
18+
},
19+
"homepage": "https://github.com/Weetbix/vue-compat-composition-api-bug-repo#readme",
20+
"dependencies": {
21+
"@testing-library/vue": "^6.6.0",
22+
"@vue/compat": "^3.2.37",
23+
"vitest": "^0.17.1",
24+
"vue": "^3.2.37"
25+
},
26+
"devDependencies": {
27+
"jsdom": "^20.0.0"
28+
}
29+
}

test.spec.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
3+
import {ref, onMounted, defineComponent} from 'vue';
4+
import {it} from 'vitest';
5+
import {render} from '@testing-library/vue';
6+
7+
function sleep(ms) {
8+
return new Promise(resolve => setTimeout(resolve, ms));
9+
}
10+
11+
const TestAsync = defineComponent({
12+
template: '<div><div>{{ mountText }}</div><div>{{ asyncText }}</div></div>',
13+
14+
setup() {
15+
const mountText = ref();
16+
const asyncText = ref();
17+
18+
onMounted(() => {
19+
mountText.value = 'mounted';
20+
});
21+
22+
sleep(0).then(() => {
23+
asyncText.value = 'async';
24+
});
25+
26+
return {
27+
mountText,
28+
asyncText,
29+
};
30+
},
31+
});
32+
33+
it('should show onMount text', async () => {
34+
const {findByText} = render(TestAsync);
35+
await findByText('mounted');
36+
});
37+
38+
it('should show async text', async () => {
39+
const {findByText} = render(TestAsync);
40+
await findByText('async');
41+
});

vite.config.compat.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from 'vite'
2+
3+
export default defineConfig({
4+
test: {
5+
environment: 'jsdom',
6+
},
7+
resolve: {
8+
alias: {
9+
vue: '@vue/compat',
10+
}
11+
}
12+
})

vite.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vite'
2+
3+
export default defineConfig({
4+
test: {
5+
environment: 'jsdom',
6+
},
7+
})

0 commit comments

Comments
 (0)