@shopify/cli-kit
    Preparing search index...

    Class DoctorSuite<TContext>Abstract

    Base class for doctor test suites.

    Write tests using the test() method.

    export default class MyTests extends DoctorSuite {
    static description = 'My test suite'

    tests() {
    this.test('basic case', async () => {
    const result = await this.run('shopify theme init')
    this.assertSuccess(result)
    })

    this.test('error case', async () => {
    const result = await this.run('shopify theme init --invalid')
    this.assertError(result, /unknown flag/)
    })
    }
    }

    Type Parameters

    Index

    Constructors

    Properties

    context: TContext
    description: string = 'Doctor test suite'

    Methods

    • Assert that a directory exists.

      Parameters

      • path: string

        The directory path to check.

      • Optionalmessage: string

        Optional custom assertion message.

      Returns Promise<void>

    • Assert that a command failed with an error matching the pattern.

      Parameters

      • result: CommandResult

        The command result to check.

      • Optionalpattern: string | RegExp

        Optional regex or string pattern to match against output.

      • Optionalmessage: string

        Optional custom assertion message.

      Returns void

    • Assert that a file exists and optionally matches content.

      Parameters

      • path: string

        The file path to check.

      • OptionalcontentPattern: string | RegExp

        Optional regex or string to match file content.

      • Optionalmessage: string

        Optional custom assertion message.

      Returns Promise<void>

    • Assert that output contains valid JSON and optionally validate it.

      Type Parameters

      • T = unknown

      Parameters

      • result: CommandResult

        The command result to parse.

      • Optionalvalidator: (json: T) => boolean

        Optional function to validate the parsed JSON.

      • Optionalmessage: string

        Optional custom assertion message.

      Returns T | undefined

    • Assert that a file does not exist.

      Parameters

      • path: string

        The file path to check.

      • Optionalmessage: string

        Optional custom assertion message.

      Returns Promise<void>

    • Assert that output contains a pattern.

      Parameters

      • result: CommandResult

        The command result to check.

      • pattern: string | RegExp

        Regex or string pattern to match against output.

      • Optionalmessage: string

        Optional custom assertion message.

      Returns void

    • Assert that a command succeeded (exit code 0).

      Parameters

      • result: CommandResult

        The command result to check.

      • Optionalmessage: string

        Optional custom assertion message.

      Returns void

    • Run a CLI command and return the result.

      Parameters

      • command: string

        The CLI command to run.

      • Optionaloptions: { cwd?: string; env?: { [key: string]: string } }

        Optional overrides.

        • Optionalcwd?: string

          Working directory for the command.

        • Optionalenv?: { [key: string]: string }

          Environment variables for the command.

      Returns Promise<CommandResult>

      const result = await this.run('shopify theme init my-theme')
      const result = await this.run('shopify theme push --json')
    • Run a command without capturing output (for interactive commands). Returns only success/failure.

      Parameters

      • command: string

        The CLI command to run.

      • Optionaloptions: { cwd?: string; env?: { [key: string]: string } }

        Optional overrides.

        • Optionalcwd?: string

          Working directory for the command.

        • Optionalenv?: { [key: string]: string }

          Environment variables for the command.

      Returns Promise<CommandResult>