Skip to content

Commit

Permalink
feat: render "typescript" icon in typecheck tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Aug 12, 2024
1 parent 37156d0 commit 5ced400
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/ui/client/components/explorer/ExplorerItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ const projectNameTextColor = computed(() => {
<div :class="opened ? 'i-carbon:chevron-down' : 'i-carbon:chevron-right op20'" op20 />
</div>
<StatusIcon :state="state" :mode="task.mode" :failed-snapshot="failedSnapshot" w-4 />
<div v-if="type === 'suite' && typecheck" class="i-logos:typescript-icon" flex-shrink-0 mr-2 />
<div flex items-end gap-2 overflow-hidden>
<div v-if="type === 'file' && typecheck" class="i-logos:typescript-icon" flex-shrink-0 />
<span text-sm truncate font-light>
<span v-if="type === 'file' && projectName" class="rounded-full p-1 mr-1 text-xs" :style="{ backgroundColor: projectNameColor, color: projectNameTextColor }">
{{ projectName }}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/client/composables/explorer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export interface ParentTreeNode extends UITaskTreeNode {
export interface SuiteTreeNode extends ParentTreeNode {
fileId: string
type: 'suite'
typecheck?: boolean
}

export interface FileTreeNode extends ParentTreeNode {
type: 'file'
filepath: string
typecheck: boolean | undefined
projectName?: string
projectNameColor: string
collectDuration?: number
Expand Down
6 changes: 2 additions & 4 deletions packages/ui/client/composables/explorer/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export function createOrUpdateFileNode(
let fileNode = explorerTree.nodes.get(file.id) as FileTreeNode | undefined

if (fileNode) {
fileNode.typecheck = !!file.meta && 'typecheck' in file.meta
fileNode.state = file.result?.state
fileNode.mode = file.mode
fileNode.duration = file.result?.duration
Expand All @@ -66,6 +67,7 @@ export function createOrUpdateFileNode(
type: 'file',
children: new Set(),
tasks: [],
typecheck: !!file.meta && 'typecheck' in file.meta,
indent: 0,
duration: file.result?.duration,
filepath: file.filepath,
Expand Down Expand Up @@ -141,9 +143,6 @@ export function createOrUpdateNode(
taskNode.mode = task.mode
taskNode.duration = task.result?.duration
taskNode.state = task.result?.state
if (isSuiteNode(taskNode)) {
taskNode.typecheck = !!task.meta && 'typecheck' in task.meta
}
}
else {
if (isAtomTest(task)) {
Expand All @@ -168,7 +167,6 @@ export function createOrUpdateNode(
parentId,
name: task.name,
mode: task.mode,
typecheck: !!task.meta && 'typecheck' in task.meta,
type: 'suite',
expandable: true,
// When the current run finish, we will expand all nodes when required, here we expand only the opened nodes
Expand Down
3 changes: 3 additions & 0 deletions packages/vitest/src/node/cli/cli-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,9 @@ export const cliOptionsConfig: VitestCLIOptions = {
ignoreSourceErrors: {
description: 'Ignore type errors from source files',
},
ignoreCollectWarnings: {
description: 'Do not show warnings from the collector during typechecking',
},
tsconfig: {
description: 'Path to a custom tsconfig file',
argument: '<path>',
Expand Down
3 changes: 3 additions & 0 deletions packages/vitest/src/node/reporters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export abstract class BaseReporter implements Reporter {
}

let title = ` ${getStateSymbol(task)} `
if (task.meta.typecheck) {
title += `${c.bgBlue(c.bold(' TS '))} `
}
if (task.projectName) {
title += formatProjectName(task.projectName)
}
Expand Down
5 changes: 5 additions & 0 deletions packages/vitest/src/node/reporters/renderers/listRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ function renderTree(
prefix += formatProjectName(task.projectName)
}

if (level === 0 && task.type === 'suite' && task.meta.typecheck) {
prefix += c.bgBlue(c.bold(' TS '))
prefix += ' '
}

if (
task.type === 'test'
&& task.result?.retryCount
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/typecheck/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export async function collectTests(
const {
arguments: [messageNode],
} = node
let message: string | null = null
let message: string = 'unknown'

if (messageNode.type === 'Literal') {
message = String(messageNode.value)
Expand Down

0 comments on commit 5ced400

Please sign in to comment.