Skip to content

Commit 60642b3

Browse files
authored
fix: fix module graph UI on html reporter with headless browser mode (#9219)
1 parent 568513c commit 60642b3

4 files changed

Lines changed: 37 additions & 3 deletions

File tree

‎packages/ui/node/reporter.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default class HTMLReporter implements Reporter {
101101
processAttachments(file)
102102
constprojectName=file.projectName||''
103103
constresolvedConfig=this.ctx.getProjectByName(projectName).config
104-
constbrowser=resolvedConfig.browser.enabled&&resolvedConfig.browser.ui
104+
constbrowser=resolvedConfig.browser.enabled
105105
result.moduleGraph[projectName]??={}
106106
result.moduleGraph[projectName][file.filepath]=awaitgetModuleGraph(
107107
this.ctx,

‎pnpm-lock.yaml‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎test/reporters/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"test": "vitest"
77
},
88
"devDependencies": {
9+
"@vitest/browser-playwright": "workspace:*",
910
"@vitest/runner": "workspace:*",
1011
"flatted": "^3.3.3",
1112
"pkg-reporter": "./reportPkg/",

‎test/reporters/tests/html.test.ts‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
importfsfrom'node:fs'
22
importzlibfrom'node:zlib'
3+
import{playwright}from'@vitest/browser-playwright'
34
import{parse}from'flatted'
45
import{resolve}from'pathe'
56
import{describe,expect,it}from'vitest'
6-
7-
import{runVitest}from'../../test-utils'
7+
import{runInlineTests,runVitest}from'../../test-utils'
88

99
describe('html reporter',async()=>{
1010
constvitestRoot=resolve(import.meta.dirname,'../../..')
@@ -100,3 +100,33 @@ describe('html reporter', async () => {
100100
expect(indexHtml).toMatch('window.METADATA_PATH="html.meta.json.gz"')
101101
},120000)
102102
})
103+
104+
it('browser mode headless',async()=>{
105+
constresult=awaitrunInlineTests({
106+
'basic.test.ts': /* ts */`
107+
import { test } from "vitest";
108+
test('basic', () => {});
109+
`,
110+
},{
111+
reporters: ['default','html'],
112+
},{},{
113+
test: {
114+
browser: {
115+
enabled: true,
116+
provider: playwright(),
117+
headless: true,
118+
instances: [
119+
{browser: 'chromium'asconst},
120+
],
121+
},
122+
},
123+
})
124+
expect(result.errorTree()).toMatchInlineSnapshot(`
125+
{
126+
"basic.test.ts": {
127+
"basic": "passed",
128+
},
129+
}
130+
`)
131+
expect(result.fs.statFile('html/index.html').isFile()).toBe(true)
132+
})

0 commit comments

Comments
 (0)