Skip to content

Commit

Permalink
Merge branch 'main' into fix-coverage-url-in-html-report-mode2
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 18, 2023
2 parents ac7eb76 + 8dabef8 commit b872e98
Show file tree
Hide file tree
Showing 22 changed files with 151 additions and 134 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": false
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

// Silent the stylistic rules in you IDE, but still auto fix them
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"vue": "latest"
},
"devDependencies": {
"@iconify-json/carbon": "^1.1.25",
"@iconify-json/logos": "^1.1.40",
"@iconify-json/carbon": "^1.1.27",
"@iconify-json/logos": "^1.1.41",
"@unocss/reset": "^0.57.4",
"@vite-pwa/assets-generator": "^0.0.11",
"@vite-pwa/vitepress": "^0.2.3",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@vitest/coverage-istanbul": "workspace:*",
"@vitest/coverage-v8": "workspace:*",
"@vitest/ui": "workspace:*",
"bumpp": "^9.2.0",
"bumpp": "^9.2.1",
"esbuild": "^0.19.5",
"eslint": "^8.54.0",
"fast-glob": "^3.3.2",
Expand Down
12 changes: 3 additions & 9 deletions packages/ui/client/components/views/ViewConsoleOutput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ import { getNames } from '@vitest/ws-client'
import { client, currentLogs as logs } from '~/composables/client'
import { isDark } from '~/composables/dark'
import { createAnsiToHtmlFilter } from '~/composables/error'
import { escapeHtml } from "~/utils/escape"
const formattedLogs = computed(() => {
const data = logs.value
if (data) {
const filter = createAnsiToHtmlFilter(isDark.value)
return data.map(({ taskId, type, time, content }) => {
const trimmed = content.trim()
const value = filter.toHtml(trimmed)
return value !== trimmed
? { taskId, type, time, html: true, content: value }
: { taskId, type, time, html: false, content }
})
return data.map(({ taskId, type, time, content }) => ({ taskId, type, time, content: filter.toHtml(escapeHtml(content)) }))
}
})
Expand All @@ -26,13 +21,12 @@ function getTaskName(id?: string) {

<template>
<div v-if="formattedLogs?.length" h-full class="scrolls" flex flex-col data-testid="logs">
<div v-for="{ taskId, type, time, html, content } of formattedLogs" :key="taskId" font-mono>
<div v-for="{ taskId, type, time, content } of formattedLogs" :key="taskId" font-mono>
<ViewConsoleOutputEntry
:task-name="getTaskName(taskId)"
:type="type"
:time="time"
:content="content"
:html="html"
/>
</div>
</div>
Expand Down
18 changes: 0 additions & 18 deletions packages/ui/client/components/views/ViewConsoleOutputEntry.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,8 @@ import Filter from 'ansi-to-html'
import ViewConsoleOutputEntry from './ViewConsoleOutputEntry.vue'

const htmlSelector = '[data-type=html]'
const textSelector = '[data-type=text]'

describe('ViewConsoleOutputEntry', () => {
it('test plain entry', () => {
const content = new Date().toISOString()
const container = cy.mount(
<ViewConsoleOutputEntry
task-name="test/text"
type="stderr"
time={Date.now()}
html={false}
content={content}
/>,
).get(textSelector)
container.should('exist')
container.invoke('text').then((t) => {
expect(t, 'the message has the correct message').equals(content)
})
})
it('test html entry', () => {
const now = new Date().toISOString()
const content = new Filter().toHtml(`\x1B[33m${now}\x1B[0m`)
Expand All @@ -29,7 +12,6 @@ describe('ViewConsoleOutputEntry', () => {
task-name="test/html"
type="stderr"
time={Date.now()}
html={true}
content={content}
/>,
).get(htmlSelector)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ defineProps<{
type: UserConsoleLog['type']
time: UserConsoleLog['time']
content: UserConsoleLog['content']
html: boolean
}>()
function formatTime(t: number) {
Expand All @@ -22,7 +21,6 @@ function formatTime(t: number) {
>
{{ formatTime(time) }} | {{ taskName }} | {{ type }}
</div>
<pre v-if="html" data-type="html" v-html="content" />
<pre v-else data-type="text" v-text="content" />
<pre data-type="html" v-html="content" />
</div>
</template>
10 changes: 1 addition & 9 deletions packages/ui/client/components/views/ViewReport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ViewReportError from './ViewReportError.vue'
import { isDark } from '~/composables/dark'
import { createAnsiToHtmlFilter } from '~/composables/error'
import { config } from '~/composables/client'
import { escapeHtml } from '~/utils/escape'
const props = defineProps<{
file?: File
Expand All @@ -24,15 +25,6 @@ function collectFailed(task: Task, level: number): LeveledTask[] {
return [{ ...task, level }, ...task.tasks.flatMap(t => collectFailed(t, level + 1))]
}
function escapeHtml(unsafe: string) {
return unsafe
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
}
function createHtmlError(filter: Convert, error: ErrorWithDiff) {
let htmlError = ''
if (error.message?.includes('\x1B'))
Expand Down
8 changes: 8 additions & 0 deletions packages/ui/client/utils/escape.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function escapeHtml(unsafe: string) {
return unsafe
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
}
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"devDependencies": {
"@faker-js/faker": "^8.2.0",
"@iconify-json/logos": "^1.1.40",
"@iconify-json/logos": "^1.1.41",
"@testing-library/cypress": "^10.0.1",
"@types/codemirror": "^5.60.13",
"@types/d3-force": "^3.0.9",
Expand Down
5 changes: 4 additions & 1 deletion packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,11 @@ export class Vitest {
'testTimeout',
'pool',
'globals',
'mode',
'expandSnapshotDiff',
'retry',
'testNamePattern',
'passWithNoTests',
'bail',
] as const

const cliOverrides = overridesOptions.reduce((acc, name) => {
Expand Down
5 changes: 2 additions & 3 deletions packages/vitest/src/node/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function initializeProject(workspacePath: string | number, ctx: Vit
logLevel: 'error',
configFile,
// this will make "mode": "test" | "benchmark" inside defineConfig
mode: options.mode || ctx.config.mode,
mode: options.test?.mode || options.mode || ctx.config.mode,
plugins: [
...options.plugins || [],
WorkspaceVitestPlugin(project, { ...options, root, workspacePath }),
Expand Down Expand Up @@ -360,8 +360,7 @@ export class WorkspaceProject {
this.server.close(),
this.typechecker?.stop(),
this.browser?.close(),
() => this._provided = ({} as any),
].filter(Boolean))
].filter(Boolean)).then(() => this._provided = {} as any)
}
return this.closingPromise
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"devDependencies": {
"@types/debug": "^4.1.12",
"@types/ungap__structured-clone": "^0.3.2",
"@types/ungap__structured-clone": "^0.3.3",
"@ungap/structured-clone": "^1.2.0"
}
}
Loading

0 comments on commit b872e98

Please sign in to comment.