chore: mount should return locator pointing to the component element / fragment (#12718)
This commit is contained in:
parent
25c0369eaf
commit
3b0a5b4753
6
package-lock.json
generated
6
package-lock.json
generated
|
|
@ -7388,7 +7388,7 @@
|
||||||
},
|
},
|
||||||
"packages/playwright-ct-react": {
|
"packages/playwright-ct-react": {
|
||||||
"name": "@playwright/experimental-ct-react",
|
"name": "@playwright/experimental-ct-react",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "1.21.0-next"
|
"@playwright/test": "1.21.0-next"
|
||||||
|
|
@ -7399,7 +7399,7 @@
|
||||||
},
|
},
|
||||||
"packages/playwright-ct-svelte": {
|
"packages/playwright-ct-svelte": {
|
||||||
"name": "@playwright/experimental-ct-svelte",
|
"name": "@playwright/experimental-ct-svelte",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "1.21.0-next"
|
"@playwright/test": "1.21.0-next"
|
||||||
|
|
@ -7410,7 +7410,7 @@
|
||||||
},
|
},
|
||||||
"packages/playwright-ct-vue": {
|
"packages/playwright-ct-vue": {
|
||||||
"name": "@playwright/experimental-ct-vue",
|
"name": "@playwright/experimental-ct-vue",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "1.21.0-next"
|
"@playwright/test": "1.21.0-next"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@playwright/experimental-ct-react",
|
"name": "@playwright/experimental-ct-react",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"description": "Playwright Component Testing for React",
|
"description": "Playwright Component Testing for React",
|
||||||
"repository": "github:Microsoft/playwright",
|
"repository": "github:Microsoft/playwright",
|
||||||
"homepage": "https://playwright.dev",
|
"homepage": "https://playwright.dev",
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,5 @@ function render(component) {
|
||||||
|
|
||||||
window.playwrightMount = component => {
|
window.playwrightMount = component => {
|
||||||
ReactDOM.render(render(component), document.getElementById('root'));
|
ReactDOM.render(render(component), document.getElementById('root'));
|
||||||
return '#root';
|
return '#root > *';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@playwright/experimental-ct-svelte",
|
"name": "@playwright/experimental-ct-svelte",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"description": "Playwright Component Testing for Svelte",
|
"description": "Playwright Component Testing for Svelte",
|
||||||
"repository": "github:Microsoft/playwright",
|
"repository": "github:Microsoft/playwright",
|
||||||
"homepage": "https://playwright.dev",
|
"homepage": "https://playwright.dev",
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,5 @@ const playwrightMount = component => {
|
||||||
|
|
||||||
for (const [key, listener] of Object.entries(component.options?.on || {}))
|
for (const [key, listener] of Object.entries(component.options?.on || {}))
|
||||||
wrapper.$on(key, event => listener(event.detail));
|
wrapper.$on(key, event => listener(event.detail));
|
||||||
return '#app';
|
return '#app > *';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@playwright/experimental-ct-vue",
|
"name": "@playwright/experimental-ct-vue",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"description": "Playwright Component Testing for Svelte",
|
"description": "Playwright Component Testing for Svelte",
|
||||||
"repository": "github:Microsoft/playwright",
|
"repository": "github:Microsoft/playwright",
|
||||||
"homepage": "https://playwright.dev",
|
"homepage": "https://playwright.dev",
|
||||||
|
|
|
||||||
|
|
@ -108,5 +108,5 @@ window.playwrightMount = async component => {
|
||||||
});
|
});
|
||||||
instance.setDevtoolsHook(createDevTools(), {});
|
instance.setDevtoolsHook(createDevTools(), {});
|
||||||
app.mount('#app');
|
app.mount('#app');
|
||||||
return '#app';
|
return '#app > *';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,6 @@ test('should work', async ({ mount }) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await expect(component).toContainText('my suffix');
|
await expect(component).toContainText('my suffix');
|
||||||
await component.locator('button').click();
|
await component.click();
|
||||||
expect(values).toEqual([{ count: 1 }]);
|
expect(values).toEqual([{ count: 1 }]);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ test('event should work', async ({ mount }) => {
|
||||||
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)
|
||||||
}}></Button>)
|
}}></Button>)
|
||||||
await component.locator('button').click()
|
await component.click()
|
||||||
expect(messages).toEqual(['hello'])
|
expect(messages).toEqual(['hello'])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ test('event should work', async ({ mount }) => {
|
||||||
submit: data => messages.push(data)
|
submit: data => messages.push(data)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
await component.locator('button').click()
|
await component.click()
|
||||||
expect(messages).toEqual(['hello'])
|
expect(messages).toEqual(['hello'])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<h1>Welcome!</h1>
|
<h1>Welcome!</h1>
|
||||||
<main>
|
<main>
|
||||||
<slot />
|
<slot />
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ test('event should work', async ({ mount }) => {
|
||||||
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)
|
||||||
}}></Button>)
|
}}></Button>)
|
||||||
await component.locator('button').click()
|
await component.click()
|
||||||
expect(messages).toEqual(['hello'])
|
expect(messages).toEqual(['hello'])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ test('event should work', async ({ mount }) => {
|
||||||
submit: data => messages.push(data)
|
submit: data => messages.push(data)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
await component.locator('button').click()
|
await component.click()
|
||||||
expect(messages).toEqual(['hello'])
|
expect(messages).toEqual(['hello'])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
import register from '@playwright/experimental-ct-vue/register'
|
|
||||||
|
|
||||||
import Button from './components/Button.vue'
|
|
||||||
import DefaultSlot from './components/DefaultSlot.vue'
|
|
||||||
import NamedSlots from './components/NamedSlots.vue'
|
|
||||||
|
|
||||||
register({
|
|
||||||
Button,
|
|
||||||
DefaultSlot,
|
|
||||||
NamedSlots
|
|
||||||
})
|
|
||||||
|
|
@ -8,6 +8,6 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="/src/tests.js"></script>
|
<script type="module" src="/tests.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
11
tests-components/ct-vue-vite/tests.js
Normal file
11
tests-components/ct-vue-vite/tests.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import register from '@playwright/experimental-ct-vue/register'
|
||||||
|
|
||||||
|
import Button from './src/components/Button.vue'
|
||||||
|
import DefaultSlot from './src/components/DefaultSlot.vue'
|
||||||
|
import NamedSlots from './src/components/NamedSlots.vue'
|
||||||
|
|
||||||
|
register({
|
||||||
|
Button,
|
||||||
|
DefaultSlot,
|
||||||
|
NamedSlots
|
||||||
|
})
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const { test } = require('@playwright/test');
|
const { test, expect } = require('@playwright/test');
|
||||||
|
|
||||||
const { spawn } = require('child_process');
|
const { spawn } = require('child_process');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
@ -9,14 +9,14 @@ for (const dir of fs.readdirSync(__dirname)) {
|
||||||
if (!fs.statSync(folder).isDirectory())
|
if (!fs.statSync(folder).isDirectory())
|
||||||
continue;
|
continue;
|
||||||
test.describe.serial(path.basename(folder), () => {
|
test.describe.serial(path.basename(folder), () => {
|
||||||
test.slow();
|
test.setTimeout(120000);
|
||||||
test('install', async () => {
|
test('install', async () => {
|
||||||
await run('npm', ['i'], folder);
|
await run('npm', ['i'], folder);
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const project of ['chromium', 'firefox', 'webkit']) {
|
for (const project of ['chromium', 'firefox', 'webkit']) {
|
||||||
test(project, async () => {
|
test(project, async () => {
|
||||||
test.slow();
|
test.setTimeout(120000);
|
||||||
await run('npx', ['playwright', 'test', '--project=' + project, '--reporter=list'], folder);
|
await run('npx', ['playwright', 'test', '--project=' + project, '--reporter=list'], folder);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -35,5 +35,6 @@ async function run(command, args, folder) {
|
||||||
process.on('exit', () => {
|
process.on('exit', () => {
|
||||||
child.kill();
|
child.kill();
|
||||||
});
|
});
|
||||||
await new Promise(f => child.on('close', f));
|
const code = await new Promise(f => child.on('close', f));
|
||||||
|
expect(code).toEqual(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue