Skip to content

Commit

Permalink
refactor: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Oct 2, 2022
1 parent 5660350 commit bc509c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
8 changes: 2 additions & 6 deletions packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,12 @@ export class Vitest {
})
checker.onParseStart(async () => {
await this.report('onInit', this)
const files = checker.getTestFiles()
if (files)
await this.report('onCollected', checker.getTestFiles())
await this.report('onCollected', checker.getTestFiles())
})
checker.onWatcherRerun(async () => {
await this.report('onWatcherRerun', testsFilesList, 'File change detected. Triggering rerun.')
await checker.collectTests()
const files = checker.getTestFiles()
if (files)
await this.report('onCollected', checker.getTestFiles())
await this.report('onCollected', checker.getTestFiles())
})
await checker.collectTests()
await checker.start()
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/node/reporters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ export abstract class BaseReporter implements Reporter {
}

if (failedTests.length) {
const type = this.mode === 'typecheck' ? 'Typechecks' : 'Tests'
logger.error(c.red(divider(c.bold(c.inverse(` Failed ${type} ${failedTests.length} `)))))
const message = this.mode === 'typecheck' ? 'Type Errors' : 'Failed Tests'
logger.error(c.red(divider(c.bold(c.inverse(` ${message} ${failedTests.length} `)))))
logger.error()

await this.printTaskErrors(failedTests, errorDivider)
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/typescript/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ export async function collectTests(ctx: Vitest, filepath: string): Promise<null
},
})
let lastSuite: ParsedSuite = file
const getLatestSuite = (index: number) => {
const updateLatestSuite = (index: number) => {
const suite = lastSuite
while (lastSuite !== file && lastSuite.end < index)
lastSuite = suite.suite as ParsedSuite
return lastSuite
}
definitions.sort((a, b) => a.start - b.start).forEach((definition, idx) => {
const latestSuite = getLatestSuite(definition.start)
const latestSuite = updateLatestSuite(definition.start)
let mode = definition.mode
if (latestSuite.mode !== 'run') // inherit suite mode, if it's set
mode = latestSuite.mode
Expand Down

0 comments on commit bc509c0

Please sign in to comment.