Skip to content

Commit 2876558

Browse files
committed
test: e2e
1 parent 0386948 commit 2876558

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/plugin-rsc/examples/basic/src/routes/browser-only/client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const BrowserDep = (
88

99
export function TestBrowserOnly() {
1010
return (
11-
<div>
11+
<div data-testid="test-browser-only">
1212
test-browser-only:{' '}
1313
<BrowserOnly fallback={<>loading...</>}>
1414
<BrowserDep />

packages/plugin-rsc/examples/basic/vite.config.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import tailwindcss from '@tailwindcss/vite'
44
import react from '@vitejs/plugin-react'
55
import { type Plugin, defineConfig, parseAstAsync } from 'vite'
66
import inspect from 'vite-plugin-inspect'
7+
import path from 'node:path'
78

89
// log unhandled rejection to debug e2e failures
910
if (!(globalThis as any).__debugHandlerRegisterd) {
@@ -97,6 +98,23 @@ export default defineConfig({
9798
}
9899
},
99100
},
101+
{
102+
name: 'test-browser-only',
103+
writeBundle(_options, bundle) {
104+
const moduleIds = Object.values(bundle).flatMap((c) =>
105+
c.type === 'chunk' ? [...c.moduleIds] : [],
106+
)
107+
const browserId = path.resolve(
108+
'src/routes/browser-only/browser-dep.tsx',
109+
)
110+
if (this.environment.name === 'client') {
111+
assert(moduleIds.includes(browserId))
112+
}
113+
if (this.environment.name === 'ssr') {
114+
assert(!moduleIds.includes(browserId))
115+
}
116+
},
117+
},
100118
{
101119
name: 'cf-build',
102120
enforce: 'post',

0 commit comments

Comments
 (0)