Skip to content

Commit

Permalink
chore: add title and fix logo path
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin committed Apr 15, 2023
1 parent 75d30f4 commit 86d9000
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/browser/src/client/index.html
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="icon" href="favicon.svg" type="image/svg+xml">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vitest Browser Runner</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/client/tester.html
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="icon" href="favicon.svg" type="image/svg+xml">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vitest Browser Runner Tester</title>
<style>
Expand Down
12 changes: 11 additions & 1 deletion packages/browser/src/node/index.ts
Expand Up @@ -30,11 +30,21 @@ export default (base = '/'): Plugin[] => {
const match = req.url?.match(testMatcher)
if (match) {
let [, test] = match
const title = ` - ${test}</title>`
if (/^\w:/.test(test))
test = `/@fs/${test}`

res.setHeader('Content-Type', 'text/html; charset=utf-8')
res.write(testerHtml.replace('</body>', `<script type="module">await runTest('${test}');</script></body>`), 'utf-8')
res.write(
testerHtml.replace(
'href="favicon.svg"', `href="${base}/favicon.svg"`.replace('//', '/'),
).replace(
'</title>', title,
).replace(
'</body>', `<script type="module">await runTest('${test}');</script></body>`,
),
'utf-8',
)
res.end()
}
else {
Expand Down

0 comments on commit 86d9000

Please sign in to comment.