playwright/tests
Max Schmitt 9fa06be49e
fix(ct): throw error if inline component is getting mounted (#32531)
What was happening?
- When we use CT, we go over the test files, look at the imports using
`tsxTransform.ts` and store them inside a map, these we feed into the
import registry which we build using Vite and have access inside the
browser
- In case of an inline component in the same file as where the test file
is, this is not happening.
- jsx-runtime via babel kicks in, transforms every JSX component in
something like that:

```
{
  __pw_type: 'jsx',
  type: [Function: MyInlineComponent],
  props: { value: 'Max' },
  key: undefined
}
```

this then gets passed into `wrapObject` which maps any function from the
Node.js side into expose function calls so they work inside the browser.
The assumption for `wrapObject` was to do it mostly for callbacks. So it
does for `type` - which is actually our component. We then pass this to
the React render function, which calls back the exposed function but we
never return anything, so it mounts `undefined`.

---

While there have been experiments from certain vendors to get the
'client only' code inside a server side file, we should throw for now to
not confuse users. We might revisit this in the future since Babel / TSX
doesn't support it outside of the box.

Fixes https://github.com/microsoft/playwright/issues/32167
2024-09-10 11:15:20 +02:00
..
android test: update to android-35 SDK (Android 15) (#32430) 2024-09-06 14:27:56 +02:00
assets feat(ui-mode): display list of query params in request tab (#32443) 2024-09-04 07:54:44 -07:00
bidi chore: run bidi firefox tests on ci (#32527) 2024-09-09 17:22:19 -07:00
components fix(ct): throw error if inline component is getting mounted (#32531) 2024-09-10 11:15:20 +02:00
config chore: roll expect and move it to third party (#32458) 2024-09-09 13:12:20 -07:00
electron chore: update flakiness metadata for better ui presentation (#31528) 2024-07-03 08:39:53 -07:00
expect chore: roll expect and move it to third party (#32458) 2024-09-09 13:12:20 -07:00
image_tools chore: bump @babel dependencies (#27632) 2023-10-17 20:52:41 +02:00
installation fix(electron): tracing with @playwright/test (#31437) 2024-07-01 19:19:38 +02:00
library chore: fix flaky screenshot test (#32517) 2024-09-09 14:00:38 +02:00
page test: worker interception for existing workers (#32494) 2024-09-06 13:17:49 -07:00
playwright-test chore: revert the matcherResult in API (#32524) 2024-09-09 16:44:32 -07:00
stress test: fix stress tests bots (#32513) 2024-09-09 12:52:40 +02:00
third_party/proxy chore: fix typos (#30645) 2024-05-08 19:40:03 +01:00
webview2 chore: update flakiness metadata for better ui presentation (#31528) 2024-07-03 08:39:53 -07:00
.eslintrc.js chore: strengthen linting (#29669) 2024-02-26 16:52:28 -08:00
tsconfig.json chore: use own socks5 server for tests (#31639) 2024-07-11 14:12:48 +02:00