Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions packages/vitest/src/create/browser/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,39 @@ test('renders name', async () => {
`,
}

const preactExample = {
name: 'HelloWorld.jsx',
js: `
export default function HelloWorld({ name }) {
return (
<div>
<h1>Hello {name}!</h1>
</div>
)
}
`,
ts: `
export default function HelloWorld({ name }: { name: string }) {
return (
<div>
<h1>Hello {name}!</h1>
</div>
)
}
`,
test: `
import { expect, test } from 'vitest'
import { render } from 'vitest-browser-preact'
import HelloWorld from '../src/HelloWorld'

test('renders name', () => {
const { getByText } = render(<HelloWorld name="Vitest" />)
const element = getByText('Hello Vitest!')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const element = getByText('Hello Vitest!')

expect(element).toBeInTheDocument()
Comment thread
WuMingDao marked this conversation as resolved.
Outdated
})
`,
}

const vanillaExample = {
name: 'HelloWorld.js',
js: `
Expand Down Expand Up @@ -274,6 +307,7 @@ function getExampleTest(framework: string) {
test: jsxExample.test.replace('@testing-library/jsx', `@testing-library/${framework}`),
}
case 'preact':
return preactExample
case 'react':
return {
...jsxExample,
Expand Down
Loading