test(ct): remove locators (#21963)
This commit is contained in:
parent
45faf0cd80
commit
5d3128a595
|
|
@ -18,8 +18,8 @@ import { useLayoutEffect, useRef, useState } from "react"
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
return <div onClick={() => props.onClick?.('hello')}>
|
return <div onClick={() => props.onClick?.('hello')}>
|
||||||
<div id="props">{ props.count }</div>
|
<div data-testid="props">{ props.count }</div>
|
||||||
<div id="remount-count">{ remountCount }</div>
|
<div data-testid="remount-count">{ remountCount }</div>
|
||||||
{ props.children }
|
{ props.children }
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,6 @@ test('execute callback when a child node is clicked', async ({ mount }) => {
|
||||||
<span onClick={() => (clickFired = true)}>Main Content</span>
|
<span onClick={() => (clickFired = true)}>Main Content</span>
|
||||||
</DefaultChildren>
|
</DefaultChildren>
|
||||||
);
|
);
|
||||||
await component.locator('text=Main Content').click();
|
await component.getByText('Main Content').click();
|
||||||
expect(clickFired).toBeTruthy();
|
expect(clickFired).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,12 @@ test('render a component as child', async ({ mount }) => {
|
||||||
test('render multiple children', async ({ mount }) => {
|
test('render multiple children', async ({ mount }) => {
|
||||||
const component = await mount(
|
const component = await mount(
|
||||||
<DefaultChildren>
|
<DefaultChildren>
|
||||||
<div id="one">One</div>
|
<div data-testid="one">One</div>
|
||||||
<div id="two">Two</div>
|
<div data-testid="two">Two</div>
|
||||||
</DefaultChildren>
|
</DefaultChildren>
|
||||||
);
|
);
|
||||||
await expect(component.locator('#one')).toContainText('One');
|
await expect(component.getByTestId('one')).toContainText('One');
|
||||||
await expect(component.locator('#two')).toContainText('Two');
|
await expect(component.getByTestId('two')).toContainText('Two');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('render named children', async ({ mount }) => {
|
test('render named children', async ({ mount }) => {
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@ import Counter from '@/components/Counter';
|
||||||
|
|
||||||
test('update props without remounting', async ({ mount }) => {
|
test('update props without remounting', async ({ mount }) => {
|
||||||
const component = await mount(<Counter count={9001} />);
|
const component = await mount(<Counter count={9001} />);
|
||||||
await expect(component.locator('#props')).toContainText('9001');
|
await expect(component.getByTestId('props')).toContainText('9001');
|
||||||
|
|
||||||
await component.update(<Counter count={1337} />);
|
await component.update(<Counter count={1337} />);
|
||||||
await expect(component).not.toContainText('9001');
|
await expect(component).not.toContainText('9001');
|
||||||
await expect(component.locator('#props')).toContainText('1337');
|
await expect(component.getByTestId('props')).toContainText('1337');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update callbacks without remounting', async ({ mount }) => {
|
test('update callbacks without remounting', async ({ mount }) => {
|
||||||
|
|
@ -26,7 +26,7 @@ test('update callbacks without remounting', async ({ mount }) => {
|
||||||
await component.click();
|
await component.click();
|
||||||
expect(messages).toEqual(['hello']);
|
expect(messages).toEqual(['hello']);
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update slots without remounting', async ({ mount }) => {
|
test('update slots without remounting', async ({ mount }) => {
|
||||||
|
|
@ -37,5 +37,5 @@ test('update slots without remounting', async ({ mount }) => {
|
||||||
await expect(component).not.toContainText('Default Slot');
|
await expect(component).not.toContainText('Default Slot');
|
||||||
await expect(component).toContainText('Test Slot');
|
await expect(component).toContainText('Test Slot');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ import { useLayoutEffect, useRef, useState } from "react"
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
return <div onClick={() => props.onClick?.('hello')}>
|
return <div onClick={() => props.onClick?.('hello')}>
|
||||||
<div id="props">{ props.count }</div>
|
<div data-testid="props">{ props.count }</div>
|
||||||
<div id="remount-count">{ remountCount }</div>
|
<div data-testid="remount-count">{ remountCount }</div>
|
||||||
{ props.children }
|
{ props.children }
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,6 @@ test('execute callback when a child node is clicked', async ({ mount }) => {
|
||||||
<span onClick={() => (clickFired = true)}>Main Content</span>
|
<span onClick={() => (clickFired = true)}>Main Content</span>
|
||||||
</DefaultChildren>
|
</DefaultChildren>
|
||||||
);
|
);
|
||||||
await component.locator('text=Main Content').click();
|
await component.getByText('Main Content').click();
|
||||||
expect(clickFired).toBeTruthy();
|
expect(clickFired).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,12 @@ test('render a component as child', async ({ mount }) => {
|
||||||
test('render multiple children', async ({ mount }) => {
|
test('render multiple children', async ({ mount }) => {
|
||||||
const component = await mount(
|
const component = await mount(
|
||||||
<DefaultChildren>
|
<DefaultChildren>
|
||||||
<div id="one">One</div>
|
<div data-testid="one">One</div>
|
||||||
<div id="two">Two</div>
|
<div data-testid="two">Two</div>
|
||||||
</DefaultChildren>
|
</DefaultChildren>
|
||||||
);
|
);
|
||||||
await expect(component.locator('#one')).toContainText('One');
|
await expect(component.getByTestId('one')).toContainText('One');
|
||||||
await expect(component.locator('#two')).toContainText('Two');
|
await expect(component.getByTestId('two')).toContainText('Two');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('render named children', async ({ mount }) => {
|
test('render named children', async ({ mount }) => {
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@ import Counter from '@/components/Counter';
|
||||||
|
|
||||||
test('update props without remounting', async ({ mount }) => {
|
test('update props without remounting', async ({ mount }) => {
|
||||||
const component = await mount(<Counter count={9001} />);
|
const component = await mount(<Counter count={9001} />);
|
||||||
await expect(component.locator('#props')).toContainText('9001');
|
await expect(component.getByTestId('props')).toContainText('9001');
|
||||||
|
|
||||||
await component.update(<Counter count={1337} />);
|
await component.update(<Counter count={1337} />);
|
||||||
await expect(component).not.toContainText('9001');
|
await expect(component).not.toContainText('9001');
|
||||||
await expect(component.locator('#props')).toContainText('1337');
|
await expect(component.getByTestId('props')).toContainText('1337');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update callbacks without remounting', async ({ mount }) => {
|
test('update callbacks without remounting', async ({ mount }) => {
|
||||||
|
|
@ -26,7 +26,7 @@ test('update callbacks without remounting', async ({ mount }) => {
|
||||||
await component.click();
|
await component.click();
|
||||||
expect(messages).toEqual(['hello']);
|
expect(messages).toEqual(['hello']);
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update slots without remounting', async ({ mount }) => {
|
test('update slots without remounting', async ({ mount }) => {
|
||||||
|
|
@ -37,5 +37,5 @@ test('update slots without remounting', async ({ mount }) => {
|
||||||
await expect(component).not.toContainText('Default Slot');
|
await expect(component).not.toContainText('Default Slot');
|
||||||
await expect(component).toContainText('Test Slot');
|
await expect(component).toContainText('Test Slot');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,6 @@ test('execute callback when a child node is clicked', async ({ mount }) => {
|
||||||
<span onClick={() => (clickFired = true)}>Main Content</span>
|
<span onClick={() => (clickFired = true)}>Main Content</span>
|
||||||
</DefaultChildren>
|
</DefaultChildren>
|
||||||
);
|
);
|
||||||
await component.locator('text=Main Content').click();
|
await component.getByText('Main Content').click();
|
||||||
expect(clickFired).toBeTruthy();
|
expect(clickFired).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ test('render a default child', async ({ mount }) => {
|
||||||
test('render multiple children', async ({ mount }) => {
|
test('render multiple children', async ({ mount }) => {
|
||||||
const component = await mount(
|
const component = await mount(
|
||||||
<DefaultChildren>
|
<DefaultChildren>
|
||||||
<div id="one">One</div>
|
<div data-testid="one">One</div>
|
||||||
<div id="two">Two</div>
|
<div data-testid="two">Two</div>
|
||||||
</DefaultChildren>
|
</DefaultChildren>
|
||||||
);
|
);
|
||||||
await expect(component.locator('#one')).toContainText('One');
|
await expect(component.getByTestId('one')).toContainText('One');
|
||||||
await expect(component.locator('#two')).toContainText('Two');
|
await expect(component.getByTestId('two')).toContainText('Two');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('render a component as child', async ({ mount }) => {
|
test('render a component as child', async ({ mount }) => {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ update();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div on:click={() => dispatch('submit', 'hello')}>
|
<div on:click={() => dispatch('submit', 'hello')}>
|
||||||
<div id="props">{count}</div>
|
<div data-testid="props">{count}</div>
|
||||||
<div id="remount-count">{remountCount}</div>
|
<div data-testid="remount-count">{remountCount}</div>
|
||||||
<slot name="main" />
|
<slot name="main" />
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,15 @@ test('update props without remounting', async ({ mount }) => {
|
||||||
const component = await mount(Counter, {
|
const component = await mount(Counter, {
|
||||||
props: { count: 9001 },
|
props: { count: 9001 },
|
||||||
});
|
});
|
||||||
await expect(component.locator('#props')).toContainText('9001');
|
await expect(component.getByTestId('props')).toContainText('9001');
|
||||||
|
|
||||||
await component.update({
|
await component.update({
|
||||||
props: { count: 1337 },
|
props: { count: 1337 },
|
||||||
});
|
});
|
||||||
await expect(component).not.toContainText('9001');
|
await expect(component).not.toContainText('9001');
|
||||||
await expect(component.locator('#props')).toContainText('1337');
|
await expect(component.getByTestId('props')).toContainText('1337');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update event listeners without remounting', async ({ mount }) => {
|
test('update event listeners without remounting', async ({ mount }) => {
|
||||||
|
|
@ -28,5 +28,5 @@ test('update event listeners without remounting', async ({ mount }) => {
|
||||||
await component.click();
|
await component.click();
|
||||||
expect(messages).toEqual(['hello']);
|
expect(messages).toEqual(['hello']);
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ update();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div on:click={() => dispatch('submit', 'hello')}>
|
<div on:click={() => dispatch('submit', 'hello')}>
|
||||||
<div id="props">{count}</div>
|
<div data-testid="props">{count}</div>
|
||||||
<div id="remount-count">{remountCount}</div>
|
<div data-testid="remount-count">{remountCount}</div>
|
||||||
<slot name="main" />
|
<slot name="main" />
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,15 @@ test('update props without remounting', async ({ mount }) => {
|
||||||
const component = await mount(Counter, {
|
const component = await mount(Counter, {
|
||||||
props: { count: 9001 },
|
props: { count: 9001 },
|
||||||
});
|
});
|
||||||
await expect(component.locator('#props')).toContainText('9001');
|
await expect(component.getByTestId('props')).toContainText('9001');
|
||||||
|
|
||||||
await component.update({
|
await component.update({
|
||||||
props: { count: 1337 },
|
props: { count: 1337 },
|
||||||
});
|
});
|
||||||
await expect(component).not.toContainText('9001');
|
await expect(component).not.toContainText('9001');
|
||||||
await expect(component.locator('#props')).toContainText('1337');
|
await expect(component.getByTestId('props')).toContainText('1337');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update event listeners without remounting', async ({ mount }) => {
|
test('update event listeners without remounting', async ({ mount }) => {
|
||||||
|
|
@ -28,5 +28,5 @@ test('update event listeners without remounting', async ({ mount }) => {
|
||||||
await component.click();
|
await component.click();
|
||||||
expect(messages).toEqual(['hello']);
|
expect(messages).toEqual(['hello']);
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<span id="remount-count">{{ remountCount }}</span>
|
<span data-testid="remount-count">{{ remountCount }}</span>
|
||||||
<span id="rerender-count">{{ count }}</span>
|
<span data-testid="rerender-count">{{ count }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,6 @@ test('emit a event when a slot is clicked', async ({ mount }) => {
|
||||||
<span v-on:click={() => (clickFired = true)}>Main Content</span>
|
<span v-on:click={() => (clickFired = true)}>Main Content</span>
|
||||||
</DefaultSlot>
|
</DefaultSlot>
|
||||||
);
|
);
|
||||||
await component.locator('text=Main Content').click();
|
await component.getByText('Main Content').click();
|
||||||
expect(clickFired).toBeTruthy();
|
expect(clickFired).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ test('renderer and keep the component instance intact', async ({ mount }) => {
|
||||||
count: 9001,
|
count: 9001,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await expect(component.locator('#rerender-count')).toContainText('9001');
|
await expect(component.getByTestId('rerender-count')).toContainText('9001');
|
||||||
|
|
||||||
await component.update({ props: { count: 1337 } });
|
await component.update({ props: { count: 1337 } });
|
||||||
await expect(component.locator('#rerender-count')).toContainText('1337');
|
await expect(component.getByTestId('rerender-count')).toContainText('1337');
|
||||||
|
|
||||||
await component.update({ props: { count: 42 } });
|
await component.update({ props: { count: 42 } });
|
||||||
await expect(component.locator('#rerender-count')).toContainText('42');
|
await expect(component.getByTestId('rerender-count')).toContainText('42');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@ import Counter from '@/components/Counter.vue';
|
||||||
|
|
||||||
test('renderer and keep the component instance intact', async ({ mount }) => {
|
test('renderer and keep the component instance intact', async ({ mount }) => {
|
||||||
const component = await mount(<Counter count={9001} />);
|
const component = await mount(<Counter count={9001} />);
|
||||||
await expect(component.locator('#rerender-count')).toContainText('9001');
|
await expect(component.getByTestId('rerender-count')).toContainText('9001');
|
||||||
|
|
||||||
await component.update(<Counter count={1337} />);
|
await component.update(<Counter count={1337} />);
|
||||||
await expect(component.locator('#rerender-count')).toContainText('1337');
|
await expect(component.getByTestId('rerender-count')).toContainText('1337');
|
||||||
|
|
||||||
await component.update(<Counter count={42} />);
|
await component.update(<Counter count={42} />);
|
||||||
await expect(component.locator('#rerender-count')).toContainText('42');
|
await expect(component.getByTestId('rerender-count')).toContainText('42');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div @click="$emit('submit', 'hello')">
|
<div @click="$emit('submit', 'hello')">
|
||||||
<div id="props">{{ count }}</div>
|
<div data-testid="props">{{ count }}</div>
|
||||||
<div id="remount-count">{{ remountCount }}</div>
|
<div data-testid="remount-count">{{ remountCount }}</div>
|
||||||
<slot name="main" />
|
<slot name="main" />
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,6 @@ test('emit a event when a slot is clicked', async ({ mount }) => {
|
||||||
<span v-on:click={() => (clickFired = true)}>Main Content</span>
|
<span v-on:click={() => (clickFired = true)}>Main Content</span>
|
||||||
</DefaultSlot>
|
</DefaultSlot>
|
||||||
);
|
);
|
||||||
await component.locator('text=Main Content').click();
|
await component.getByText('Main Content').click();
|
||||||
expect(clickFired).toBeTruthy();
|
expect(clickFired).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,15 @@ test('update props without remounting', async ({ mount }) => {
|
||||||
const component = await mount(Counter, {
|
const component = await mount(Counter, {
|
||||||
props: { count: 9001 },
|
props: { count: 9001 },
|
||||||
});
|
});
|
||||||
await expect(component.locator('#props')).toContainText('9001');
|
await expect(component.getByTestId('props')).toContainText('9001');
|
||||||
|
|
||||||
await component.update({
|
await component.update({
|
||||||
props: { count: 1337 },
|
props: { count: 1337 },
|
||||||
});
|
});
|
||||||
await expect(component).not.toContainText('9001');
|
await expect(component).not.toContainText('9001');
|
||||||
await expect(component.locator('#props')).toContainText('1337');
|
await expect(component.getByTestId('props')).toContainText('1337');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update event listeners without remounting', async ({ mount }) => {
|
test('update event listeners without remounting', async ({ mount }) => {
|
||||||
|
|
@ -28,7 +28,7 @@ test('update event listeners without remounting', async ({ mount }) => {
|
||||||
await component.click();
|
await component.click();
|
||||||
expect(messages).toEqual(['hello']);
|
expect(messages).toEqual(['hello']);
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update slots without remounting', async ({ mount }) => {
|
test('update slots without remounting', async ({ mount }) => {
|
||||||
|
|
@ -43,5 +43,5 @@ test('update slots without remounting', async ({ mount }) => {
|
||||||
await expect(component).not.toContainText('Default Slot');
|
await expect(component).not.toContainText('Default Slot');
|
||||||
await expect(component).toContainText('Test Slot');
|
await expect(component).toContainText('Test Slot');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,15 @@ test('update props without remounting', async ({ mount }) => {
|
||||||
const component = await mount(Counter, {
|
const component = await mount(Counter, {
|
||||||
props: { count: 9001 },
|
props: { count: 9001 },
|
||||||
});
|
});
|
||||||
await expect(component.locator('#props')).toContainText('9001');
|
await expect(component.getByTestId('props')).toContainText('9001');
|
||||||
|
|
||||||
await component.update({
|
await component.update({
|
||||||
props: { count: 1337 },
|
props: { count: 1337 },
|
||||||
});
|
});
|
||||||
await expect(component).not.toContainText('9001');
|
await expect(component).not.toContainText('9001');
|
||||||
await expect(component.locator('#props')).toContainText('1337');
|
await expect(component.getByTestId('props')).toContainText('1337');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update event listeners without remounting', async ({ mount }) => {
|
test('update event listeners without remounting', async ({ mount }) => {
|
||||||
|
|
@ -28,7 +28,7 @@ test('update event listeners without remounting', async ({ mount }) => {
|
||||||
await component.click();
|
await component.click();
|
||||||
expect(messages).toEqual(['hello']);
|
expect(messages).toEqual(['hello']);
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update slots without remounting', async ({ mount }) => {
|
test('update slots without remounting', async ({ mount }) => {
|
||||||
|
|
@ -43,5 +43,5 @@ test('update slots without remounting', async ({ mount }) => {
|
||||||
await expect(component).not.toContainText('Default Slot');
|
await expect(component).not.toContainText('Default Slot');
|
||||||
await expect(component).toContainText('Test Slot');
|
await expect(component).toContainText('Test Slot');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@ import Counter from '@/components/Counter.vue';
|
||||||
|
|
||||||
test('update props without remounting', async ({ mount }) => {
|
test('update props without remounting', async ({ mount }) => {
|
||||||
const component = await mount(<Counter count={9001} />);
|
const component = await mount(<Counter count={9001} />);
|
||||||
await expect(component.locator('#props')).toContainText('9001');
|
await expect(component.getByTestId('props')).toContainText('9001');
|
||||||
|
|
||||||
await component.update(<Counter count={1337} />);
|
await component.update(<Counter count={1337} />);
|
||||||
await expect(component).not.toContainText('9001');
|
await expect(component).not.toContainText('9001');
|
||||||
await expect(component.locator('#props')).toContainText('1337');
|
await expect(component.getByTestId('props')).toContainText('1337');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update event listeners without remounting', async ({ mount }) => {
|
test('update event listeners without remounting', async ({ mount }) => {
|
||||||
|
|
@ -26,7 +26,7 @@ test('update event listeners without remounting', async ({ mount }) => {
|
||||||
await component.click();
|
await component.click();
|
||||||
expect(messages).toEqual(['hello']);
|
expect(messages).toEqual(['hello']);
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update slots without remounting', async ({ mount }) => {
|
test('update slots without remounting', async ({ mount }) => {
|
||||||
|
|
@ -41,5 +41,5 @@ test('update slots without remounting', async ({ mount }) => {
|
||||||
await expect(component).not.toContainText('Default Slot');
|
await expect(component).not.toContainText('Default Slot');
|
||||||
await expect(component).toContainText('Test Slot');
|
await expect(component).toContainText('Test Slot');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div @click="$emit('submit', 'hello')">
|
<div @click="$emit('submit', 'hello')">
|
||||||
<div id="props">{{ count }}</div>
|
<div data-testid="props">{{ count }}</div>
|
||||||
<div id="remount-count">{{ remountCount }}</div>
|
<div data-testid="remount-count">{{ remountCount }}</div>
|
||||||
<slot name="main" />
|
<slot name="main" />
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,6 @@ test('emit a event when a slot is clicked', async ({ mount }) => {
|
||||||
<span v-on:click={() => (clickFired = true)}>Main Content</span>
|
<span v-on:click={() => (clickFired = true)}>Main Content</span>
|
||||||
</DefaultSlot>
|
</DefaultSlot>
|
||||||
);
|
);
|
||||||
await component.locator('text=Main Content').click();
|
await component.getByText('Main Content').click();
|
||||||
expect(clickFired).toBeTruthy();
|
expect(clickFired).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@ test('render a component as slot', async ({ mount }) => {
|
||||||
test('render a component with multiple slots', async ({ mount }) => {
|
test('render a component with multiple slots', async ({ mount }) => {
|
||||||
const component = await mount(
|
const component = await mount(
|
||||||
<DefaultSlot>
|
<DefaultSlot>
|
||||||
<div id="one">One</div>
|
<div data-testid="one">One</div>
|
||||||
<div id="two">Two</div>
|
<div data-testid="two">Two</div>
|
||||||
</DefaultSlot>
|
</DefaultSlot>
|
||||||
);
|
);
|
||||||
await expect(component.locator('#one')).toContainText('One');
|
await expect(component.getByTestId('one')).toContainText('One');
|
||||||
await expect(component.locator('#two')).toContainText('Two');
|
await expect(component.getByTestId('two')).toContainText('Two');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('render a component with a named slot', async ({ mount }) => {
|
test('render a component with a named slot', async ({ mount }) => {
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,15 @@ test('update props without remounting', async ({ mount }) => {
|
||||||
const component = await mount(Counter, {
|
const component = await mount(Counter, {
|
||||||
props: { count: 9001 },
|
props: { count: 9001 },
|
||||||
});
|
});
|
||||||
await expect(component.locator('#props')).toContainText('9001');
|
await expect(component.getByTestId('props')).toContainText('9001');
|
||||||
|
|
||||||
await component.update({
|
await component.update({
|
||||||
props: { count: 1337 },
|
props: { count: 1337 },
|
||||||
});
|
});
|
||||||
await expect(component).not.toContainText('9001');
|
await expect(component).not.toContainText('9001');
|
||||||
await expect(component.locator('#props')).toContainText('1337');
|
await expect(component.getByTestId('props')).toContainText('1337');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update event listeners without remounting', async ({ mount }) => {
|
test('update event listeners without remounting', async ({ mount }) => {
|
||||||
|
|
@ -28,7 +28,7 @@ test('update event listeners without remounting', async ({ mount }) => {
|
||||||
await component.click();
|
await component.click();
|
||||||
expect(messages).toEqual(['hello']);
|
expect(messages).toEqual(['hello']);
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update slots without remounting', async ({ mount }) => {
|
test('update slots without remounting', async ({ mount }) => {
|
||||||
|
|
@ -48,5 +48,5 @@ test('update slots without remounting', async ({ mount }) => {
|
||||||
});
|
});
|
||||||
await expect(component).toContainText('Default Slot');
|
await expect(component).toContainText('Default Slot');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@ import Counter from '@/components/Counter.vue';
|
||||||
|
|
||||||
test('update props without remounting', async ({ mount }) => {
|
test('update props without remounting', async ({ mount }) => {
|
||||||
const component = await mount(<Counter count={9001} />);
|
const component = await mount(<Counter count={9001} />);
|
||||||
await expect(component.locator('#props')).toContainText('9001');
|
await expect(component.getByTestId('props')).toContainText('9001');
|
||||||
|
|
||||||
await component.update(<Counter count={1337} />);
|
await component.update(<Counter count={1337} />);
|
||||||
await expect(component).not.toContainText('9001');
|
await expect(component).not.toContainText('9001');
|
||||||
await expect(component.locator('#props')).toContainText('1337');
|
await expect(component.getByTestId('props')).toContainText('1337');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update event listeners without remounting', async ({ mount }) => {
|
test('update event listeners without remounting', async ({ mount }) => {
|
||||||
|
|
@ -26,7 +26,7 @@ test('update event listeners without remounting', async ({ mount }) => {
|
||||||
await component.click();
|
await component.click();
|
||||||
expect(messages).toEqual(['hello']);
|
expect(messages).toEqual(['hello']);
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('update slots without remounting', async ({ mount }) => {
|
test('update slots without remounting', async ({ mount }) => {
|
||||||
|
|
@ -41,5 +41,5 @@ test('update slots without remounting', async ({ mount }) => {
|
||||||
await expect(component).not.toContainText('Default Slot');
|
await expect(component).not.toContainText('Default Slot');
|
||||||
await expect(component).toContainText('Test Slot');
|
await expect(component).toContainText('Test Slot');
|
||||||
|
|
||||||
await expect(component.locator('#remount-count')).toContainText('1');
|
await expect(component.getByTestId('remount-count')).toContainText('1');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue