core(ct): rename tests (#17216)

This commit is contained in:
sand4rt 2022-09-12 18:27:53 +02:00 committed by GitHub
parent 81bcbd284f
commit 72a18754ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 94 additions and 94 deletions

View File

@ -7,7 +7,7 @@ import Counter from './components/Counter';
test.use({ viewport: { width: 500, height: 500 } }); test.use({ viewport: { width: 500, height: 500 } });
test('props should work', async ({ mount }) => { test('render props', async ({ mount }) => {
const component = await mount(<Button title="Submit" />); const component = await mount(<Button title="Submit" />);
await expect(component).toContainText('Submit'); await expect(component).toContainText('Submit');
}); });
@ -47,7 +47,7 @@ test('renderer updates slots without remounting', async ({ mount }) => {
await expect(component.locator('#remount-count')).toContainText('1') await expect(component.locator('#remount-count')).toContainText('1')
}) })
test('callback should work', async ({ mount }) => { test('execute callback when the button is clicked', async ({ mount }) => {
const messages: string[] = [] const messages: string[] = []
const component = await mount(<Button title="Submit" onClick={data => { const component = await mount(<Button title="Submit" onClick={data => {
messages.push(data) messages.push(data)
@ -56,14 +56,14 @@ test('callback should work', async ({ mount }) => {
expect(messages).toEqual(['hello']) expect(messages).toEqual(['hello'])
}) })
test('default slot should work', async ({ mount }) => { test('render a default child', async ({ mount }) => {
const component = await mount(<DefaultChildren> const component = await mount(<DefaultChildren>
Main Content Main Content
</DefaultChildren>) </DefaultChildren>)
await expect(component).toContainText('Main Content') await expect(component).toContainText('Main Content')
}) })
test('multiple children should work', async ({ mount }) => { test('render multiple children', async ({ mount }) => {
const component = await mount(<DefaultChildren> const component = await mount(<DefaultChildren>
<div id="one">One</div> <div id="one">One</div>
<div id="two">Two</div> <div id="two">Two</div>
@ -72,7 +72,7 @@ test('multiple children should work', async ({ mount }) => {
await expect(component.locator('#two')).toContainText('Two') await expect(component.locator('#two')).toContainText('Two')
}) })
test('named children should work', async ({ mount }) => { test('render named children', async ({ mount }) => {
const component = await mount(<MultipleChildren> const component = await mount(<MultipleChildren>
<div>Header</div> <div>Header</div>
<div>Main Content</div> <div>Main Content</div>
@ -83,7 +83,7 @@ test('named children should work', async ({ mount }) => {
await expect(component).toContainText('Footer') await expect(component).toContainText('Footer')
}) })
test('children should callback', async ({ mount }) => { test('execute callback when a child node is clicked', async ({ mount }) => {
let clickFired = false; let clickFired = false;
const component = await mount(<DefaultChildren> const component = await mount(<DefaultChildren>
<span onClick={() => clickFired = true}>Main Content</span> <span onClick={() => clickFired = true}>Main Content</span>
@ -92,7 +92,7 @@ test('children should callback', async ({ mount }) => {
expect(clickFired).toBeTruthy(); expect(clickFired).toBeTruthy();
}) })
test('should run hooks', async ({ page, mount }) => { test('run hooks', async ({ page, mount }) => {
const messages: string[] = []; const messages: string[] = [];
page.on('console', m => messages.push(m.text())); page.on('console', m => messages.push(m.text()));
await mount(<Button title="Submit" />, { await mount(<Button title="Submit" />, {
@ -103,14 +103,14 @@ test('should run hooks', async ({ page, mount }) => {
expect(messages).toEqual(['Before mount: {\"route\":\"A\"}', 'After mount']); expect(messages).toEqual(['Before mount: {\"route\":\"A\"}', 'After mount']);
}); });
test('should unmount', async ({ page, mount }) => { test('unmount', async ({ page, mount }) => {
const component = await mount(<Button title="Submit" />) const component = await mount(<Button title="Submit" />)
await expect(page.locator('#root')).toContainText('Submit') await expect(page.locator('#root')).toContainText('Submit')
await component.unmount(); await component.unmount();
await expect(page.locator('#root')).not.toContainText('Submit'); await expect(page.locator('#root')).not.toContainText('Submit');
}); });
test('unmount a multi root component should work', async ({ mount, page }) => { test('unmount a multi root component', async ({ mount, page }) => {
const component = await mount(<MultiRoot />) const component = await mount(<MultiRoot />)
await expect(page.locator('#root')).toContainText('root 1') await expect(page.locator('#root')).toContainText('root 1')
await expect(page.locator('#root')).toContainText('root 2') await expect(page.locator('#root')).toContainText('root 2')

View File

@ -10,7 +10,7 @@ import Counter from './components/Counter';
test.use({ viewport: { width: 500, height: 500 } }); test.use({ viewport: { width: 500, height: 500 } });
test('props should work', async ({ mount }) => { test('render props', async ({ mount }) => {
const component = await mount(<Button title="Submit" />); const component = await mount(<Button title="Submit" />);
await expect(component).toContainText('Submit'); await expect(component).toContainText('Submit');
}); });
@ -50,7 +50,7 @@ test('renderer updates slots without remounting', async ({ mount }) => {
await expect(component.locator('#remount-count')).toContainText('1') await expect(component.locator('#remount-count')).toContainText('1')
}); });
test('callback should work', async ({ mount }) => { test('execute callback when the button is clicked', async ({ mount }) => {
const messages: string[] = [] const messages: string[] = []
const component = await mount(<Button title="Submit" onClick={data => { const component = await mount(<Button title="Submit" onClick={data => {
messages.push(data) messages.push(data)
@ -59,14 +59,14 @@ test('callback should work', async ({ mount }) => {
expect(messages).toEqual(['hello']) expect(messages).toEqual(['hello'])
}) })
test('default slot should work', async ({ mount }) => { test('render a default child', async ({ mount }) => {
const component = await mount(<DefaultChildren> const component = await mount(<DefaultChildren>
Main Content Main Content
</DefaultChildren>) </DefaultChildren>)
await expect(component).toContainText('Main Content') await expect(component).toContainText('Main Content')
}) })
test('multiple children should work', async ({ mount }) => { test('render multiple children', async ({ mount }) => {
const component = await mount(<DefaultChildren> const component = await mount(<DefaultChildren>
<div id="one">One</div> <div id="one">One</div>
<div id="two">Two</div> <div id="two">Two</div>
@ -75,7 +75,7 @@ test('multiple children should work', async ({ mount }) => {
await expect(component.locator('#two')).toContainText('Two') await expect(component.locator('#two')).toContainText('Two')
}) })
test('named children should work', async ({ mount }) => { test('render named children', async ({ mount }) => {
const component = await mount(<MultipleChildren> const component = await mount(<MultipleChildren>
<div>Header</div> <div>Header</div>
<div>Main Content</div> <div>Main Content</div>
@ -86,7 +86,7 @@ test('named children should work', async ({ mount }) => {
await expect(component).toContainText('Footer') await expect(component).toContainText('Footer')
}) })
test('children should callback', async ({ mount }) => { test('execute callback when a child node is clicked', async ({ mount }) => {
let clickFired = false; let clickFired = false;
const component = await mount(<DefaultChildren> const component = await mount(<DefaultChildren>
<span onClick={() => clickFired = true}>Main Content</span> <span onClick={() => clickFired = true}>Main Content</span>
@ -95,7 +95,7 @@ test('children should callback', async ({ mount }) => {
expect(clickFired).toBeTruthy(); expect(clickFired).toBeTruthy();
}) })
test('should run hooks', async ({ page, mount }) => { test('run hooks', async ({ page, mount }) => {
const messages: string[] = []; const messages: string[] = [];
page.on('console', m => messages.push(m.text())); page.on('console', m => messages.push(m.text()));
await mount(<Button title="Submit" />, { await mount(<Button title="Submit" />, {
@ -106,14 +106,14 @@ test('should run hooks', async ({ page, mount }) => {
expect(messages).toEqual(['Before mount: {\"route\":\"A\"}', 'After mount']); expect(messages).toEqual(['Before mount: {\"route\":\"A\"}', 'After mount']);
}); });
test('should unmount', async ({ page, mount }) => { test('unmount', async ({ page, mount }) => {
const component = await mount(<Button title="Submit" />) const component = await mount(<Button title="Submit" />)
await expect(page.locator('#root')).toContainText('Submit') await expect(page.locator('#root')).toContainText('Submit')
await component.unmount(); await component.unmount();
await expect(page.locator('#root')).not.toContainText('Submit'); await expect(page.locator('#root')).not.toContainText('Submit');
}); });
test('unmount a multi root component should work', async ({ mount, page }) => { test('unmount a multi root component', async ({ mount, page }) => {
const component = await mount(<MultiRoot />) const component = await mount(<MultiRoot />)
await expect(page.locator('#root')).toContainText('root 1') await expect(page.locator('#root')).toContainText('root 1')
await expect(page.locator('#root')).toContainText('root 2') await expect(page.locator('#root')).toContainText('root 2')
@ -122,7 +122,7 @@ test('unmount a multi root component should work', async ({ mount, page }) => {
await expect(page.locator('#root')).not.toContainText('root 2') await expect(page.locator('#root')).not.toContainText('root 2')
}) })
test('toHaveText works on delayed data', async ({ mount }) => { test('render delayed data', async ({ mount }) => {
const component = await mount(<DelayedData data='complete' />); const component = await mount(<DelayedData data='complete' />);
await expect(component).toHaveText('complete'); await expect(component).toHaveText('complete');
}); });

View File

@ -5,12 +5,12 @@ import MultiRoot from './components/MultiRoot';
test.use({ viewport: { width: 500, height: 500 } }); test.use({ viewport: { width: 500, height: 500 } });
test('props should work', async ({ mount }) => { test('render props', async ({ mount }) => {
const component = await mount(<Button title="Submit" />); const component = await mount(<Button title="Submit" />);
await expect(component).toContainText('Submit'); await expect(component).toContainText('Submit');
}); });
test('callback should work', async ({ mount }) => { test('execute callback when the button is clicked', async ({ mount }) => {
const messages: string[] = [] const messages: string[] = []
const component = await mount(<Button title="Submit" onClick={data => { const component = await mount(<Button title="Submit" onClick={data => {
messages.push(data) messages.push(data)
@ -26,7 +26,7 @@ test('default child should work', async ({ mount }) => {
await expect(component).toContainText('Main Content') await expect(component).toContainText('Main Content')
}) })
test('should run hooks', async ({ page, mount }) => { test('run hooks', async ({ page, mount }) => {
const messages: string[] = []; const messages: string[] = [];
page.on('console', m => messages.push(m.text())); page.on('console', m => messages.push(m.text()));
await mount(<Button title="Submit" />, { await mount(<Button title="Submit" />, {
@ -37,14 +37,14 @@ test('should run hooks', async ({ page, mount }) => {
expect(messages).toEqual(['Before mount: {\"route\":\"A\"}', 'After mount']); expect(messages).toEqual(['Before mount: {\"route\":\"A\"}', 'After mount']);
}); });
test('should unmount', async ({ page, mount }) => { test('unmount', async ({ page, mount }) => {
const component = await mount(<Button title="Submit" />) const component = await mount(<Button title="Submit" />)
await expect(page.locator('#root')).toContainText('Submit') await expect(page.locator('#root')).toContainText('Submit')
await component.unmount(); await component.unmount();
await expect(page.locator('#root')).not.toContainText('Submit'); await expect(page.locator('#root')).not.toContainText('Submit');
}); });
test('unmount a multi root component should work', async ({ mount, page }) => { test('unmount a multi root component', async ({ mount, page }) => {
const component = await mount(<MultiRoot />) const component = await mount(<MultiRoot />)
await expect(page.locator('#root')).toContainText('root 1') await expect(page.locator('#root')).toContainText('root 1')
await expect(page.locator('#root')).toContainText('root 2') await expect(page.locator('#root')).toContainText('root 2')

View File

@ -21,7 +21,7 @@ import MultiRoot from './components/MultiRoot.svelte';
test.use({ viewport: { width: 500, height: 500 } }); test.use({ viewport: { width: 500, height: 500 } });
test('props should work', async ({ mount }) => { test('render props', async ({ mount }) => {
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
title: 'Submit' title: 'Submit'
@ -30,7 +30,7 @@ test('props should work', async ({ mount }) => {
await expect(component).toContainText('Submit') await expect(component).toContainText('Submit')
}) })
test('event should work', async ({ mount }) => { test('emit an submit event when the button is clicked', async ({ mount }) => {
const messages = [] const messages = []
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
@ -44,7 +44,7 @@ test('event should work', async ({ mount }) => {
expect(messages).toEqual(['hello']) expect(messages).toEqual(['hello'])
}) })
test('default slot should work', async ({ mount }) => { test('render a default slot', async ({ mount }) => {
const component = await mount(DefaultSlot, { const component = await mount(DefaultSlot, {
slots: { slots: {
default: 'Main Content' default: 'Main Content'
@ -53,7 +53,7 @@ test('default slot should work', async ({ mount }) => {
await expect(component).toContainText('Main Content') await expect(component).toContainText('Main Content')
}) })
test('should run hooks', async ({ page, mount }) => { test('run hooks', async ({ page, mount }) => {
const messages = [] const messages = []
page.on('console', m => messages.push(m.text())) page.on('console', m => messages.push(m.text()))
await mount(Button, { await mount(Button, {
@ -65,7 +65,7 @@ test('should run hooks', async ({ page, mount }) => {
expect(messages).toEqual(['Before mount: {\"route\":\"A\"}', 'After mount']); expect(messages).toEqual(['Before mount: {\"route\":\"A\"}', 'After mount']);
}) })
test('should unmount', async ({ page, mount }) => { test('unmount', async ({ page, mount }) => {
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
title: 'Submit' title: 'Submit'
@ -76,7 +76,7 @@ test('should unmount', async ({ page, mount }) => {
await expect(page.locator('#root')).not.toContainText('Submit'); await expect(page.locator('#root')).not.toContainText('Submit');
}); });
test('unmount a multi root component should work', async ({ mount, page }) => { test('unmount a multi root component', async ({ mount, page }) => {
const component = await mount(MultiRoot) const component = await mount(MultiRoot)
await expect(page.locator('#root')).toContainText('root 1') await expect(page.locator('#root')).toContainText('root 1')
await expect(page.locator('#root')).toContainText('root 2') await expect(page.locator('#root')).toContainText('root 2')

View File

@ -21,7 +21,7 @@ import MultiRoot from './components/MultiRoot.svelte';
test.use({ viewport: { width: 500, height: 500 } }); test.use({ viewport: { width: 500, height: 500 } });
test('props should work', async ({ mount }) => { test('render props', async ({ mount }) => {
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
title: 'Submit' title: 'Submit'
@ -30,7 +30,7 @@ test('props should work', async ({ mount }) => {
await expect(component).toContainText('Submit') await expect(component).toContainText('Submit')
}) })
test('event should work', async ({ mount }) => { test('emit an submit event when the button is clicked', async ({ mount }) => {
const messages = [] const messages = []
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
@ -44,7 +44,7 @@ test('event should work', async ({ mount }) => {
expect(messages).toEqual(['hello']) expect(messages).toEqual(['hello'])
}) })
test('default slot should work', async ({ mount }) => { test('render a default slot', async ({ mount }) => {
const component = await mount(DefaultSlot, { const component = await mount(DefaultSlot, {
slots: { slots: {
default: 'Main Content' default: 'Main Content'
@ -53,7 +53,7 @@ test('default slot should work', async ({ mount }) => {
await expect(component).toContainText('Main Content') await expect(component).toContainText('Main Content')
}) })
test('should run hooks', async ({ page, mount }) => { test('run hooks', async ({ page, mount }) => {
const messages = [] const messages = []
page.on('console', m => messages.push(m.text())) page.on('console', m => messages.push(m.text()))
await mount(Button, { await mount(Button, {
@ -65,7 +65,7 @@ test('should run hooks', async ({ page, mount }) => {
expect(messages).toEqual(['Before mount: {\"route\":\"A\"}', 'After mount']); expect(messages).toEqual(['Before mount: {\"route\":\"A\"}', 'After mount']);
}) })
test('should unmount', async ({ page, mount }) => { test('unmount', async ({ page, mount }) => {
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
title: 'Submit' title: 'Submit'
@ -76,7 +76,7 @@ test('should unmount', async ({ page, mount }) => {
await expect(page.locator('#root')).not.toContainText('Submit'); await expect(page.locator('#root')).not.toContainText('Submit');
}); });
test('unmount a multi root component should work', async ({ mount, page }) => { test('unmount a multi root component', async ({ mount, page }) => {
const component = await mount(MultiRoot) const component = await mount(MultiRoot)
await expect(page.locator('#root')).toContainText('root 1') await expect(page.locator('#root')).toContainText('root 1')
await expect(page.locator('#root')).toContainText('root 2') await expect(page.locator('#root')).toContainText('root 2')

View File

@ -7,7 +7,7 @@ import MultiRoot from './components/MultiRoot.vue'
test.use({ viewport: { width: 500, height: 500 } }) test.use({ viewport: { width: 500, height: 500 } })
test('props should work', async ({ mount }) => { test('render props', async ({ mount }) => {
const component = await mount(<Button title="Submit" />) const component = await mount(<Button title="Submit" />)
await expect(component).toContainText('Submit') await expect(component).toContainText('Submit')
}) })
@ -25,7 +25,7 @@ test('renderer and keep the component instance intact', async ({ mount }) => {
await expect(component.locator('#remount-count')).toContainText('1') await expect(component.locator('#remount-count')).toContainText('1')
}) })
test('event should work', async ({ mount }) => { test('emit an submit event when the button is clicked', async ({ mount }) => {
const messages = [] const messages = []
const component = await mount(<Button title='Submit' v-on:submit={data => { const component = await mount(<Button title='Submit' v-on:submit={data => {
messages.push(data) messages.push(data)
@ -34,14 +34,14 @@ test('event should work', async ({ mount }) => {
expect(messages).toEqual(['hello']) expect(messages).toEqual(['hello'])
}) })
test('default slot should work', async ({ mount }) => { test('render a default slot', async ({ mount }) => {
const component = await mount(<DefaultSlot> const component = await mount(<DefaultSlot>
Main Content Main Content
</DefaultSlot>) </DefaultSlot>)
await expect(component).toContainText('Main Content') await expect(component).toContainText('Main Content')
}) })
test('multiple slots should work', async ({ mount }) => { test('render a component with multiple children', async ({ mount }) => {
const component = await mount(<DefaultSlot> const component = await mount(<DefaultSlot>
<div id="one">One</div> <div id="one">One</div>
<div id="two">Two</div> <div id="two">Two</div>
@ -50,7 +50,7 @@ test('multiple slots should work', async ({ mount }) => {
await expect(component.locator('#two')).toContainText('Two') await expect(component.locator('#two')).toContainText('Two')
}) })
test('named slots should work', async ({ mount }) => { test('render a component with a named slot', async ({ mount }) => {
const component = await mount(<NamedSlots> const component = await mount(<NamedSlots>
<template v-slot:header> <template v-slot:header>
Header Header
@ -67,7 +67,7 @@ test('named slots should work', async ({ mount }) => {
await expect(component).toContainText('Footer') await expect(component).toContainText('Footer')
}) })
test('slot should emit events', async ({ mount }) => { test('emit a event when a slot is clicked', async ({ mount }) => {
let clickFired = false; let clickFired = false;
const component = await mount(<DefaultSlot> const component = await mount(<DefaultSlot>
<span v-on:click={() => clickFired = true}>Main Content</span> <span v-on:click={() => clickFired = true}>Main Content</span>
@ -76,7 +76,7 @@ test('slot should emit events', async ({ mount }) => {
expect(clickFired).toBeTruthy(); expect(clickFired).toBeTruthy();
}) })
test('should run hooks', async ({ page, mount }) => { test('run hooks', async ({ page, mount }) => {
const messages = [] const messages = []
page.on('console', m => messages.push(m.text())) page.on('console', m => messages.push(m.text()))
await mount(<Button title="Submit" />, { await mount(<Button title="Submit" />, {
@ -85,7 +85,7 @@ test('should run hooks', async ({ page, mount }) => {
expect(messages).toEqual(['Before mount: {\"route\":\"A\"}, app: true', 'After mount el: HTMLButtonElement']) expect(messages).toEqual(['Before mount: {\"route\":\"A\"}, app: true', 'After mount el: HTMLButtonElement'])
}) })
test('unmount a multi root component should work', async ({ mount, page }) => { test('unmount a multi root component', async ({ mount, page }) => {
const component = await mount(<MultiRoot />) const component = await mount(<MultiRoot />)
await expect(page.locator('#root')).toContainText('root 1') await expect(page.locator('#root')).toContainText('root 1')
await expect(page.locator('#root')).toContainText('root 2') await expect(page.locator('#root')).toContainText('root 2')

View File

@ -9,7 +9,7 @@ import Component from './components/Component.vue'
test.use({ viewport: { width: 500, height: 500 } }) test.use({ viewport: { width: 500, height: 500 } })
test('props should work', async ({ mount }) => { test('render props', async ({ mount }) => {
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
title: 'Submit' title: 'Submit'
@ -35,7 +35,7 @@ test('renderer and keep the component instance intact', async ({ mount }) => {
await expect(component.locator('#remount-count')).toContainText('1') await expect(component.locator('#remount-count')).toContainText('1')
}) })
test('event should work', async ({ mount }) => { test('emit an submit event when the button is clicked', async ({ mount }) => {
const messages = [] const messages = []
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
@ -49,7 +49,7 @@ test('event should work', async ({ mount }) => {
expect(messages).toEqual(['hello']) expect(messages).toEqual(['hello'])
}) })
test('default slot should work', async ({ mount }) => { test('render a default slot', async ({ mount }) => {
const component = await mount(DefaultSlot, { const component = await mount(DefaultSlot, {
slots: { slots: {
default: 'Main Content' default: 'Main Content'
@ -58,7 +58,7 @@ test('default slot should work', async ({ mount }) => {
await expect(component).toContainText('Main Content') await expect(component).toContainText('Main Content')
}) })
test('multiple slots should work', async ({ mount }) => { test('render a component with multiple slots', async ({ mount }) => {
const component = await mount(DefaultSlot, { const component = await mount(DefaultSlot, {
slots: { slots: {
default: ['one', 'two'] default: ['one', 'two']
@ -68,7 +68,7 @@ test('multiple slots should work', async ({ mount }) => {
await expect(component).toContainText('two') await expect(component).toContainText('two')
}) })
test('named slots should work', async ({ mount }) => { test('render a component with a named slot', async ({ mount }) => {
const component = await mount(NamedSlots, { const component = await mount(NamedSlots, {
slots: { slots: {
header: 'Header', header: 'Header',
@ -81,12 +81,12 @@ test('named slots should work', async ({ mount }) => {
await expect(component).toContainText('Footer') await expect(component).toContainText('Footer')
}) })
test('optionless should work', async ({ mount }) => { test('render a component without options', async ({ mount }) => {
const component = await mount(Component) const component = await mount(Component)
await expect(component).toContainText('test') await expect(component).toContainText('test')
}) })
test('should run hooks', async ({ page, mount }) => { test('run hooks', async ({ page, mount }) => {
const messages = [] const messages = []
page.on('console', m => messages.push(m.text())) page.on('console', m => messages.push(m.text()))
await mount(Button, { await mount(Button, {
@ -98,7 +98,7 @@ test('should run hooks', async ({ page, mount }) => {
expect(messages).toEqual(['Before mount: {\"route\":\"A\"}, app: true', 'After mount el: HTMLButtonElement']) expect(messages).toEqual(['Before mount: {\"route\":\"A\"}, app: true', 'After mount el: HTMLButtonElement'])
}) })
test('should unmount', async ({ page, mount }) => { test('unmount', async ({ page, mount }) => {
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
title: 'Submit' title: 'Submit'
@ -109,7 +109,7 @@ test('should unmount', async ({ page, mount }) => {
await expect(page.locator('#root')).not.toContainText('Submit'); await expect(page.locator('#root')).not.toContainText('Submit');
}); });
test('unmount a multi root component should work', async ({ mount, page }) => { test('unmount a multi root component', async ({ mount, page }) => {
const component = await mount(MultiRoot) const component = await mount(MultiRoot)
await expect(page.locator('#root')).toContainText('root 1') await expect(page.locator('#root')).toContainText('root 1')
await expect(page.locator('#root')).toContainText('root 2') await expect(page.locator('#root')).toContainText('root 2')

View File

@ -7,7 +7,7 @@ import MultiRoot from './components/MultiRoot.vue'
test.use({ viewport: { width: 500, height: 500 } }) test.use({ viewport: { width: 500, height: 500 } })
test('props should work', async ({ mount }) => { test('render props', async ({ mount }) => {
const component = await mount(<Button title="Submit" />) const component = await mount(<Button title="Submit" />)
await expect(component).toContainText('Submit') await expect(component).toContainText('Submit')
}) })
@ -25,7 +25,7 @@ test('renderer and keep the component instance intact', async ({ mount }) => {
await expect(component.locator('#remount-count')).toContainText('1') await expect(component.locator('#remount-count')).toContainText('1')
}) })
test('event should work', async ({ mount }) => { test('emit an submit event when the button is clicked', async ({ mount }) => {
const messages = [] const messages = []
const component = await mount(<Button title='Submit' v-on:submit={data => { const component = await mount(<Button title='Submit' v-on:submit={data => {
messages.push(data) messages.push(data)
@ -34,14 +34,14 @@ test('event should work', async ({ mount }) => {
expect(messages).toEqual(['hello']) expect(messages).toEqual(['hello'])
}) })
test('default slot should work', async ({ mount }) => { test('render a default slot', async ({ mount }) => {
const component = await mount(<DefaultSlot> const component = await mount(<DefaultSlot>
Main Content Main Content
</DefaultSlot>) </DefaultSlot>)
await expect(component).toContainText('Main Content') await expect(component).toContainText('Main Content')
}) })
test('multiple slots should work', async ({ mount }) => { test('render a component with multiple slots', async ({ mount }) => {
const component = await mount(<DefaultSlot> const component = await mount(<DefaultSlot>
<div id="one">One</div> <div id="one">One</div>
<div id="two">Two</div> <div id="two">Two</div>
@ -50,7 +50,7 @@ test('multiple slots should work', async ({ mount }) => {
await expect(component.locator('#two')).toContainText('Two') await expect(component.locator('#two')).toContainText('Two')
}) })
test('named slots should work', async ({ mount }) => { test('render a component with a named slot', async ({ mount }) => {
const component = await mount(<NamedSlots> const component = await mount(<NamedSlots>
<template v-slot:header> <template v-slot:header>
Header Header
@ -67,7 +67,7 @@ test('named slots should work', async ({ mount }) => {
await expect(component).toContainText('Footer') await expect(component).toContainText('Footer')
}) })
test('slot should emit events', async ({ mount }) => { test('emit a event when a slot is clicked', async ({ mount }) => {
let clickFired = false; let clickFired = false;
const component = await mount(<DefaultSlot> const component = await mount(<DefaultSlot>
<span v-on:click={() => clickFired = true}>Main Content</span> <span v-on:click={() => clickFired = true}>Main Content</span>
@ -76,7 +76,7 @@ test('slot should emit events', async ({ mount }) => {
expect(clickFired).toBeTruthy(); expect(clickFired).toBeTruthy();
}) })
test('should run hooks', async ({ page, mount }) => { test('run hooks', async ({ page, mount }) => {
const messages = [] const messages = []
page.on('console', m => messages.push(m.text())) page.on('console', m => messages.push(m.text()))
await mount(<Button title="Submit" />, { await mount(<Button title="Submit" />, {
@ -85,7 +85,7 @@ test('should run hooks', async ({ page, mount }) => {
expect(messages).toEqual(['Before mount: {\"route\":\"A\"}, app: true', 'After mount el: HTMLButtonElement']) expect(messages).toEqual(['Before mount: {\"route\":\"A\"}, app: true', 'After mount el: HTMLButtonElement'])
}) })
test('unmount a multi root component should work', async ({ mount, page }) => { test('unmount a multi root component', async ({ mount, page }) => {
const component = await mount(<MultiRoot />) const component = await mount(<MultiRoot />)
await expect(page.locator('#root')).toContainText('root 1') await expect(page.locator('#root')).toContainText('root 1')

View File

@ -8,7 +8,7 @@ import Component from './components/Component.vue'
test.use({ viewport: { width: 500, height: 500 } }) test.use({ viewport: { width: 500, height: 500 } })
test('props should work', async ({ mount }) => { test('render props', async ({ mount }) => {
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
title: 'Submit' title: 'Submit'
@ -35,7 +35,7 @@ test('renderer and keep the component instance intact', async ({ mount }) => {
}) })
test('event should work', async ({ mount }) => { test('emit an submit event when the button is clicked', async ({ mount }) => {
const messages = [] const messages = []
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
@ -49,7 +49,7 @@ test('event should work', async ({ mount }) => {
expect(messages).toEqual(['hello']) expect(messages).toEqual(['hello'])
}) })
test('default slot should work', async ({ mount }) => { test('render a default slot', async ({ mount }) => {
const component = await mount(DefaultSlot, { const component = await mount(DefaultSlot, {
slots: { slots: {
default: 'Main Content' default: 'Main Content'
@ -58,7 +58,7 @@ test('default slot should work', async ({ mount }) => {
await expect(component).toContainText('Main Content') await expect(component).toContainText('Main Content')
}) })
test('multiple slots should work', async ({ mount }) => { test('render a component with multiple slots', async ({ mount }) => {
const component = await mount(DefaultSlot, { const component = await mount(DefaultSlot, {
slots: { slots: {
default: ['one', 'two'] default: ['one', 'two']
@ -68,7 +68,7 @@ test('multiple slots should work', async ({ mount }) => {
await expect(component).toContainText('two') await expect(component).toContainText('two')
}) })
test('named slots should work', async ({ mount }) => { test('render a component with a named slot', async ({ mount }) => {
const component = await mount(NamedSlots, { const component = await mount(NamedSlots, {
slots: { slots: {
header: 'Header', header: 'Header',
@ -81,12 +81,12 @@ test('named slots should work', async ({ mount }) => {
await expect(component).toContainText('Footer') await expect(component).toContainText('Footer')
}) })
test('optionless should work', async ({ mount }) => { test('render a component without options', async ({ mount }) => {
const component = await mount(Component) const component = await mount(Component)
await expect(component).toContainText('test') await expect(component).toContainText('test')
}) })
test('should run hooks', async ({ page, mount }) => { test('run hooks', async ({ page, mount }) => {
const messages = [] const messages = []
page.on('console', m => messages.push(m.text())) page.on('console', m => messages.push(m.text()))
await mount(Button, { await mount(Button, {
@ -98,7 +98,7 @@ test('should run hooks', async ({ page, mount }) => {
expect(messages).toEqual(['Before mount: {\"route\":\"A\"}, app: true', 'After mount el: HTMLButtonElement']) expect(messages).toEqual(['Before mount: {\"route\":\"A\"}, app: true', 'After mount el: HTMLButtonElement'])
}) })
test('unmount a multi root component should work', async ({ mount, page }) => { test('unmount a multi root component', async ({ mount, page }) => {
const component = await mount(MultiRoot) const component = await mount(MultiRoot)
await expect(page.locator('#root')).toContainText('root 1') await expect(page.locator('#root')).toContainText('root 1')

View File

@ -9,7 +9,7 @@ import Component from './components/Component.vue'
test.use({ viewport: { width: 500, height: 500 } }) test.use({ viewport: { width: 500, height: 500 } })
test('props should work', async ({ mount }) => { test('render props', async ({ mount }) => {
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
title: 'Submit' title: 'Submit'
@ -35,7 +35,7 @@ test('renderer and keep the component instance intact', async ({ mount }) => {
await expect(component.locator('#remount-count')).toContainText('1') await expect(component.locator('#remount-count')).toContainText('1')
}) })
test('event should work', async ({ mount }) => { test('emit an submit event when the button is clicked', async ({ mount }) => {
const messages = [] const messages = []
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
@ -49,7 +49,7 @@ test('event should work', async ({ mount }) => {
expect(messages).toEqual(['hello']) expect(messages).toEqual(['hello'])
}) })
test('default slot should work', async ({ mount }) => { test('render a default slot', async ({ mount }) => {
const component = await mount(DefaultSlot, { const component = await mount(DefaultSlot, {
slots: { slots: {
default: 'Main Content' default: 'Main Content'
@ -58,7 +58,7 @@ test('default slot should work', async ({ mount }) => {
await expect(component).toContainText('Main Content') await expect(component).toContainText('Main Content')
}) })
test('multiple slots should work', async ({ mount }) => { test('render a component with multiple slots', async ({ mount }) => {
const component = await mount(DefaultSlot, { const component = await mount(DefaultSlot, {
slots: { slots: {
default: ['one', 'two'] default: ['one', 'two']
@ -68,7 +68,7 @@ test('multiple slots should work', async ({ mount }) => {
await expect(component).toContainText('two') await expect(component).toContainText('two')
}) })
test('named slots should work', async ({ mount }) => { test('render a component with a named slot', async ({ mount }) => {
const component = await mount(NamedSlots, { const component = await mount(NamedSlots, {
slots: { slots: {
header: 'Header', header: 'Header',
@ -81,12 +81,12 @@ test('named slots should work', async ({ mount }) => {
await expect(component).toContainText('Footer') await expect(component).toContainText('Footer')
}) })
test('optionless should work', async ({ mount }) => { test('render a component without options', async ({ mount }) => {
const component = await mount(Component) const component = await mount(Component)
await expect(component).toContainText('test') await expect(component).toContainText('test')
}) })
test('should run hooks', async ({ page, mount }) => { test('run hooks', async ({ page, mount }) => {
const messages = [] const messages = []
page.on('console', m => messages.push(m.text())) page.on('console', m => messages.push(m.text()))
await mount(Button, { await mount(Button, {
@ -98,7 +98,7 @@ test('should run hooks', async ({ page, mount }) => {
expect(messages).toEqual(['Before mount: {\"route\":\"A\"}, app: true', 'After mount el: HTMLButtonElement']) expect(messages).toEqual(['Before mount: {\"route\":\"A\"}, app: true', 'After mount el: HTMLButtonElement'])
}) })
test('should unmount', async ({ page, mount }) => { test('unmount', async ({ page, mount }) => {
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
title: 'Submit' title: 'Submit'
@ -109,7 +109,7 @@ test('should unmount', async ({ page, mount }) => {
await expect(page.locator('#root')).not.toContainText('Submit'); await expect(page.locator('#root')).not.toContainText('Submit');
}); });
test('unmount a multi root component should work', async ({ mount, page }) => { test('unmount a multi root component', async ({ mount, page }) => {
const component = await mount(MultiRoot) const component = await mount(MultiRoot)
await expect(page.locator('#root')).toContainText('root 1') await expect(page.locator('#root')).toContainText('root 1')

View File

@ -6,7 +6,7 @@ import NamedSlots from './components/NamedSlots.vue'
test.use({ viewport: { width: 500, height: 500 } }) test.use({ viewport: { width: 500, height: 500 } })
test('props should work', async ({ mount }) => { test('render props', async ({ mount }) => {
const component = await mount(<Button title="Submit" />) const component = await mount(<Button title="Submit" />)
await expect(component).toContainText('Submit') await expect(component).toContainText('Submit')
}) })
@ -24,7 +24,7 @@ test('renderer and keep the component instance intact', async ({ mount }) => {
await expect(component.locator('#remount-count')).toContainText('1') await expect(component.locator('#remount-count')).toContainText('1')
}) })
test('event should work', async ({ mount }) => { test('emit an submit event when the button is clicked', async ({ mount }) => {
const messages = [] const messages = []
const component = await mount(<Button title='Submit' v-on:submit={data => { const component = await mount(<Button title='Submit' v-on:submit={data => {
messages.push(data) messages.push(data)
@ -33,14 +33,14 @@ test('event should work', async ({ mount }) => {
expect(messages).toEqual(['hello']) expect(messages).toEqual(['hello'])
}) })
test('default slot should work', async ({ mount }) => { test('render a default slot', async ({ mount }) => {
const component = await mount(<DefaultSlot> const component = await mount(<DefaultSlot>
Main Content Main Content
</DefaultSlot>) </DefaultSlot>)
await expect(component).toContainText('Main Content') await expect(component).toContainText('Main Content')
}) })
test('multiple slots should work', async ({ mount }) => { test('render a component with multiple slots', async ({ mount }) => {
const component = await mount(<DefaultSlot> const component = await mount(<DefaultSlot>
<div id="one">One</div> <div id="one">One</div>
<div id="two">Two</div> <div id="two">Two</div>
@ -49,7 +49,7 @@ test('multiple slots should work', async ({ mount }) => {
await expect(component.locator('#two')).toContainText('Two') await expect(component.locator('#two')).toContainText('Two')
}) })
test('named slots should work', async ({ mount }) => { test('render a component with a named slot', async ({ mount }) => {
const component = await mount(<NamedSlots> const component = await mount(<NamedSlots>
<template v-slot:header> <template v-slot:header>
Header Header
@ -66,7 +66,7 @@ test('named slots should work', async ({ mount }) => {
await expect(component).toContainText('Footer') await expect(component).toContainText('Footer')
}) })
test('slot should emit events', async ({ mount }) => { test('emit a event when a slot is clicked', async ({ mount }) => {
let clickFired = false; let clickFired = false;
const component = await mount(<DefaultSlot> const component = await mount(<DefaultSlot>
<span v-on:click={() => clickFired = true}>Main Content</span> <span v-on:click={() => clickFired = true}>Main Content</span>
@ -75,7 +75,7 @@ test('slot should emit events', async ({ mount }) => {
expect(clickFired).toBeTruthy(); expect(clickFired).toBeTruthy();
}) })
test('should run hooks', async ({ page, mount }) => { test('run hooks', async ({ page, mount }) => {
const messages = [] const messages = []
page.on('console', m => messages.push(m.text())) page.on('console', m => messages.push(m.text()))
await mount(<Button title="Submit" />, { await mount(<Button title="Submit" />, {

View File

@ -7,7 +7,7 @@ import Component from './components/Component.vue'
test.use({ viewport: { width: 500, height: 500 } }) test.use({ viewport: { width: 500, height: 500 } })
test('props should work', async ({ mount }) => { test('render props', async ({ mount }) => {
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
title: 'Submit' title: 'Submit'
@ -33,7 +33,7 @@ test('renderer and keep the component instance intact', async ({ mount }) => {
await expect(component.locator('#remount-count')).toContainText('1') await expect(component.locator('#remount-count')).toContainText('1')
}) })
test('event should work', async ({ mount }) => { test('emit an submit event when the button is clicked', async ({ mount }) => {
const messages = [] const messages = []
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
@ -47,7 +47,7 @@ test('event should work', async ({ mount }) => {
expect(messages).toEqual(['hello']) expect(messages).toEqual(['hello'])
}) })
test('default slot should work', async ({ mount }) => { test('render a default slot', async ({ mount }) => {
const component = await mount(DefaultSlot, { const component = await mount(DefaultSlot, {
slots: { slots: {
default: 'Main Content' default: 'Main Content'
@ -56,7 +56,7 @@ test('default slot should work', async ({ mount }) => {
await expect(component).toContainText('Main Content') await expect(component).toContainText('Main Content')
}) })
test('multiple slots should work', async ({ mount }) => { test('render a component with multiple slots', async ({ mount }) => {
const component = await mount(DefaultSlot, { const component = await mount(DefaultSlot, {
slots: { slots: {
default: ['one', 'two'] default: ['one', 'two']
@ -66,7 +66,7 @@ test('multiple slots should work', async ({ mount }) => {
await expect(component).toContainText('two') await expect(component).toContainText('two')
}) })
test('named slots should work', async ({ mount }) => { test('render a component with a named slot', async ({ mount }) => {
const component = await mount(NamedSlots, { const component = await mount(NamedSlots, {
slots: { slots: {
header: 'Header', header: 'Header',
@ -79,12 +79,12 @@ test('named slots should work', async ({ mount }) => {
await expect(component).toContainText('Footer') await expect(component).toContainText('Footer')
}) })
test('optionless should work', async ({ mount }) => { test('render a component without options', async ({ mount }) => {
const component = await mount(Component) const component = await mount(Component)
await expect(component).toContainText('test') await expect(component).toContainText('test')
}) })
test('should run hooks', async ({ page, mount }) => { test('run hooks', async ({ page, mount }) => {
const messages = [] const messages = []
page.on('console', m => messages.push(m.text())) page.on('console', m => messages.push(m.text()))
await mount(Button, { await mount(Button, {
@ -96,7 +96,7 @@ test('should run hooks', async ({ page, mount }) => {
expect(messages).toEqual(['Before mount: {\"route\":\"A\"}', 'After mount el: HTMLButtonElement']) expect(messages).toEqual(['Before mount: {\"route\":\"A\"}', 'After mount el: HTMLButtonElement'])
}) })
test('should unmount', async ({ page, mount }) => { test('unmount', async ({ page, mount }) => {
const component = await mount(Button, { const component = await mount(Button, {
props: { props: {
title: 'Submit' title: 'Submit'

View File

@ -249,7 +249,7 @@ test('beforeAll/afterAll hooks are skipped when no tests in the suite are run 2'
expect(result.output).not.toContain('%%afterAll'); expect(result.output).not.toContain('%%afterAll');
}); });
test('should run hooks after failure', async ({ runInlineTest }) => { test('run hooks after failure', async ({ runInlineTest }) => {
const result = await runInlineTest({ const result = await runInlineTest({
'a.test.js': ` 'a.test.js': `
const { test } = pwt; const { test } = pwt;