Skip to content

Commit

Permalink
chore: rename typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Oct 26, 2022
1 parent 9ea09f1 commit 2b5d9cc
Show file tree
Hide file tree
Showing 10 changed files with 298 additions and 412 deletions.
4 changes: 2 additions & 2 deletions packages/vitest/src/runtime/collect.ts
Expand Up @@ -102,7 +102,7 @@ export async function collectTests(paths: string[], config: ResolvedConfig): Pro
/**
* If any tasks been marked as `only`, mark all other tasks as `skip`.
*/
function interpretTaskModes(suite: Suite, namePattern?: string | RegExp, onlyMode?: boolean, parentIsOnly?: boolean, allowOnly?: boolean) {
export function interpretTaskModes(suite: Suite, namePattern?: string | RegExp, onlyMode?: boolean, parentIsOnly?: boolean, allowOnly?: boolean) {
const suiteIsOnly = parentIsOnly || suite.mode === 'only'

suite.tasks.forEach((t) => {
Expand Down Expand Up @@ -145,7 +145,7 @@ function getTaskFullName(task: TaskBase): string {
return `${task.suite ? `${getTaskFullName(task.suite)} ` : ''}${task.name}`
}

function someTasksAreOnly(suite: Suite): boolean {
export function someTasksAreOnly(suite: Suite): boolean {
return suite.tasks.some(t => t.mode === 'only' || (t.type === 'suite' && someTasksAreOnly(t)))
}

Expand Down
File renamed without changes.
Expand Up @@ -4,6 +4,7 @@ import { ancestor as walkAst } from 'acorn-walk'
import type { RawSourceMap } from 'vite-node'

import type { File, Suite, Vitest } from '../types'
import { interpretTaskModes, someTasksAreOnly } from '../runtime/collect'
import { TYPECHECK_SUITE } from './constants'

interface ParsedFile extends File {
Expand Down Expand Up @@ -129,20 +130,8 @@ export async function collectTests(ctx: Vitest, filepath: string): Promise<null
// to show correct amount of "tests" in summary, we mark this with a special symbol
Object.defineProperty(task, TYPECHECK_SUITE, { value: true })
})
const markSkippedTests = (suite: Suite) => {
const hasOnly = suite.tasks.some(task => task.mode === 'only')
suite.tasks.forEach((task) => {
if ((hasOnly && task.mode !== 'only') || suite.mode === 'skip') {
task.mode = 'skip'
task.result = {
state: 'skip',
}
}
if (task.type === 'suite')
markSkippedTests(task)
})
}
markSkippedTests(file)
const hasOnly = someTasksAreOnly(file)
interpretTaskModes(file, ctx.config.testNamePattern, hasOnly, false, ctx.config.allowOnly)
return {
file,
parsed: request.code,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2b5d9cc

Please sign in to comment.