切换vitest-browser
This commit is contained in:
11
vitest-example/HelloWorld.test.ts
Normal file
11
vitest-example/HelloWorld.test.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { expect, test } from 'vitest'
|
||||
import { getByText } from '@testing-library/dom'
|
||||
import HelloWorld from './HelloWorld.js'
|
||||
|
||||
test('renders name', () => {
|
||||
const parent = HelloWorld({ name: 'Vitest' })
|
||||
document.body.appendChild(parent)
|
||||
|
||||
const element = getByText(parent, 'Hello Vitest!')
|
||||
expect(element).toBeInTheDocument()
|
||||
})
|
9
vitest-example/HelloWorld.ts
Normal file
9
vitest-example/HelloWorld.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export default function HelloWorld({ name }: { name: string }): HTMLDivElement {
|
||||
const parent = document.createElement('div')
|
||||
|
||||
const h1 = document.createElement('h1')
|
||||
h1.textContent = 'Hello ' + name + '!'
|
||||
parent.appendChild(h1)
|
||||
|
||||
return parent
|
||||
}
|
Reference in New Issue
Block a user