Skip to content

Commit c03dae4

Browse files
committed
✅ test: 子コンポーネントのレンダリングテストを追加
子コンポーネントが正しくレンダリングされているかのテストを追加 ISSUES CLOSED: #34
1 parent a1e8a7e commit c03dae4

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { describe, expect, test } from 'vitest';
2+
import ParentComponent from '@/components/mount/ParentComponent.vue';
3+
import { mountSuspendedComponent } from '@/helpers/test';
4+
5+
describe('src/components/mount/ParentComponent.vue', () => {
6+
test('子コンポーネントが正しくレンダリングされているか(stub)', async () => {
7+
const ChildComponent = {
8+
template: '<div id="test">Child Component Stub</div>',
9+
};
10+
const stubs = { ChildComponent };
11+
const wrapper = await mountSuspendedComponent(ParentComponent, { stubs });
12+
13+
expect(wrapper.exists()).toBe(true);
14+
expect(wrapper.findComponent(ChildComponent).exists()).toBe(true);
15+
});
16+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<div id="child-component">Child Component</div>
3+
</template>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script setup lang="ts">
2+
import ChildComponent from '@/components/mount/ChildComponent.vue';
3+
</script>
4+
<template>
5+
<div id="parent-component">
6+
<ChildComponent />
7+
</div>
8+
</template>

src/pages/mount/index.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<script setup lang="ts">
22
import Mount from '@/components/mount/Mount.vue';
3+
import ParentComponent from '@/components/mount/ParentComponent.vue';
34
</script>
45
<template>
5-
<Mount />
6+
<section>
7+
<Mount />
8+
<ParentComponent />
9+
</section>
610
</template>

0 commit comments

Comments
 (0)