Skip to content

Enhance importBreakdown support #9141

@sheremet-va

Description

@sheremet-va

Clear and concise description of the problem

At the moment Vitest can only show information about import breakdown. It would be nice to be able to control it and react to the duration.

Related: #9105

Suggested solution

Enhance the import breakdown feature with these options (WIP):

interface ImportBreakdownOptions {
  /**
   * Always show an import breakdown after the test summary.
   * @default false
   */
  enabled?: boolean
  /**
   * If Vitest finds a file that takes longer than `experimental.importDurationThresholds.warn`,
   * it will show an Import Breakdown.
   *
   * Imports Breakdown is always shown in UI inside the "Module Graph" tab.
   * @default true
   */
  warnInTerminal?: boolean
  /**
   * Fail the test run if there is a module that takes longer than `experimental.importDurationThresholds.danger`.
   */
  // failOnDanger?: boolean
  importDurationThresholds?: {
    /**
     * Warning threshold in milliseconds. Warning are shown in orange/yellow color.
     * @default 100
     */
    warn?: number
    /**
     * Danger threshold in milliseconds. These are shown in red color.
     * @defaul 500
     */
    danger?: number
  },
  // @default 10
  // throw error if less than 0
  // 0 is Infinity
  limit?: number
}

Turn self/total into a column

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-nice-to-haveNot breaking anything but nice to have (priority)

    Projects

    Status

    Approved

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions