better error message
This commit is contained in:
parent
7b040a075d
commit
1bdb9d57cd
|
|
@ -68,8 +68,9 @@ export function transformObject(value: any, mapping: (v: any) => { result: any }
|
||||||
}
|
}
|
||||||
if (value?.__pw_type === 'jsx' && typeof value.type === 'function') {
|
if (value?.__pw_type === 'jsx' && typeof value.type === 'function') {
|
||||||
throw new Error([
|
throw new Error([
|
||||||
'JSX component was not able to get resolved.',
|
`Component "${value.type.name}" cannot be mounted.`,
|
||||||
'Make sure to define components outside of your test file.'
|
`Most likely, this component is defined in the test file. Create a test story instead.`,
|
||||||
|
`For more information, see https://playwright.dev/docs/test-components#test-stories.`,
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
}
|
}
|
||||||
const result2: any = {};
|
const result2: any = {};
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,11 @@ function MyInlineComponent({ value }: { value: string }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
test('render inline component with an error', async ({ mount }) => {
|
test('render inline component with an error', async ({ mount }) => {
|
||||||
await expect(mount(<MyInlineComponent value="Max" />)).rejects.toThrow('JSX component was not able to get resolved');
|
await expect(mount(<MyInlineComponent value="Max" />)).rejects.toThrow('Component "MyInlineComponent" cannot be mounted.');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('render inline component with an error if its nested', async ({ mount }) => {
|
test('render inline component with an error if its nested', async ({ mount }) => {
|
||||||
await expect(mount(<DefaultChildren>
|
await expect(mount(<DefaultChildren>
|
||||||
<MyInlineComponent value="Max" />
|
<MyInlineComponent value="Max" />
|
||||||
</DefaultChildren>)).rejects.toThrow('JSX component was not able to get resolved');
|
</DefaultChildren>)).rejects.toThrow('Component "MyInlineComponent" cannot be mounted.');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue