{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "additionalProperties": true,
  "definitions": {
    "engineOptions": {
      "type": "object",
      "description": "The options to configure the chosen browser engine for Chutzpah to use.",
      "properties": {
        "ChromeBrowserPath": {
          "description": "The path to the chrome/chromium executable on the machine",
          "type": "string"
        }
      }
    },
    "serverSettings": {
      "description": "Server settings let you enable to configure Chutzpah web server mode.",
      "type": "object",
      "properties": {
        "Enabled": {
          "description": "Determines if the web server mode is enabled.",
          "type": "boolean",
          "default": false
        },
        "DefaultPort": {
          "description": "The default port to use. If this port is taken Chutzpah will try incrementing until it finds an available one.",
          "type": "number"
        },
        "RootPath": {
          "description": "The root path of the server. All file paths are relative to this and should be in a directory below or equal to this. Defaults to drive root.",
          "type": "string"
        }
      }
    },
    "templateOptions": {
      "properties": {
        "Mode": {
          "description": "The way the template is injected into the HTML page.",
          "enum": ["Raw", "Script"],
          "default": "Raw"
        },
        "Id": {
          "description": "If in script mode what Id to place on the script tag.",
          "type": "string"
        },
        "Type": {
          "description": "If in script mode what Type to place on script tag",
          "type": "string"
        }
      }
    },
    "referenceSettings": {
      "properties": {
        "Path": {
          "description": "The path to either a file or a folder. If given a folder, it will be scanned recursively. This path can be relative to the location of the chutzpah.json file.",
          "type": "string"
        },
        "Includes": {
          "description": "This is an optional array of include glob patterns. Only files matching the Include pattern will be added.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "Excludes": {
          "description": "This is an optional array of exclude glob patterns.  Only files not matching the Exclude patterns will be added.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "IncludeInTestHarness": {
          "description": "This determines if the reference should be injected into the test harness. When referencing files like .d.ts or files that you plan to load using require.js you should set this to false. Defaults to true.",
          "type": "boolean",
          "default": true
        },
        "IsTestFrameworkFile": {
          "description": "Indicated that this references should be placed directly after the test framework files in the test harness. This ensures that this file is injected into the test harness before almost all other files. Defaults to false.",
          "type": "boolean",
          "default": false
        },
        "TemplateOptions": {
          "$ref": "#/definitions/templateOptions"
        }
      }
    },
    "compilePathMap": {
      "properties": {
        "SourcePath": {
          "description": "The source file/directory",
          "type": "string"
        },
        "OutputPath": {
          "description": "The file/directory that source file/directory is mapped to. Specifying a file OutputPath and a directory for SourcePath indicated the files are being concatenated into one large file",
          "type": "string"
        },
        "OutputPathType": {
          "description": "The type (file or folder) that the output path refers to. If not specified Chutzpah will try to take a best guess by assuming it is a file if it has a .js extension",
          "type": "string",
          "enum": ["File", "Folder"],
          "default": "Folder"
        }
      }
    },
    "testSettings": {
      "properties": {
        "Path": {
          "description": "The path to either a file or a folder. If given a folder, it will be scanned recursively. This path can be relative to the location of the chutzpah.json file.",
          "type": "string"
        },
        "Includes": {
          "description": "This is an optional array of include glob patterns. Only files matching the Include pattern will be added.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "Excludes": {
          "description": "This is an optional array of exclude glob patterns.  Only files not matching the Exclude patterns will be added.",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "transformConfig": {
      "properties": {
        "Name": {
          "description": "The name of the transform to execute",
          "type": "string"
        },
        "Path": {
          "description": "The file for the transform to save its output to.",
          "type": "string"
        }
      }
    },
    "compileSettings": {
      "description": "This setting lets you describe in the Chutzpah.json file how to execute a command which can compile your source files to .js files. You tell Chutzpah what to execute and some information about what your executable does (like where to find the generated .js files). Then after running the executable Chutzpah can associate each source file with each output file to still give the nice behavior of mapping tests back to their original files.",
      "type": "object",
      "properties": {
        "Extensions": {
          "description": "The extensions of the files which are getting compiled (e.g. .ts).",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "ExtensionsWithNoOutput": {
          "description": "The extensions of files which take part in compile but have no build output. This is used for cases like TypeScript declaration files which share a .ts extension. They have .d.ts extension and are part of compilation but have no output. You must tell Chutzpah about these if you want the SkipIfUnchanged setting to work. Otherwise Chutzpah will think these are missing output.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "Paths": {
          "description": " The collection of path mapping from source directory/file to output directory/file.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/compilePathMap"
          }
        },
        "WorkingDirectory": {
          "description": "This is the working directory of the process which executes the command.",
          "type": "string"
        },
        "Executable": {
          "description": "The path to an executable which Chutzpah executes to perform the batch compilation. Chutzpah will try to resolve the path relative to the settings directory. But if can't find the file there you must give it a full path.",
          "type": ["string", "null"],
          "default": null
        },
        "Arguments": {
          "description": "The arguments to pass to the command.",
          "type": ["string", "null"],
          "default": null
        },
        "Timeout": {
          "description": "How long to wait for compile to finish in milliseconds?",
          "type": "integer",
          "default": 30000
        },
        "SkipIfUnchanged": {
          "description": "Skips the execution if all files Chutzpah knows about are older than all of the output files. This is defaulted to true but if you hit issues since it is possible Chutzpah might not know about all the files your compilation is using then you can turn this off. Ideally you should tell Chutzpah about these files using the references and tests settings since this setting helps Chutzpah not need to even invoke the executable if it figures out it's not needed.",
          "type": "boolean",
          "default": true
        },
        "Mode": {
          "description": "Determines how this compile setting is used. By default it is in Executable mode where it will require you provide an executable which Chutzpah will run if it sees it finds missing .js for input file. If you set this to External then Chutzpah will ignore the Executable, Arguments settings and assume you have some external process which is compiling. In this case Chutzpah will use the SourceDirectory and OutDirectory options to try to find your .js files for the input files. If it can't find them it will trace an error but still attempt to proceed.",
          "type": "string",
          "enum": ["Executable", "External"],
          "default": "External"
        },
        "UseSourceMaps": {
          "description": "Configures whether .map files should be loaded (if available) to convert under-test JS line numbers to those of their original source files.",
          "type": "boolean",
          "default": false
        },
        "IgnoreMissingFiles": {
          "description": "Should Chutzpah ignore files it expects to find compiled. If set to true Chutzpah will log an error otherwise it will throw",
          "type": "boolean",
          "default": false
        }
      }
    }
  },
  "id": "https://json.schemastore.org/chutzpah.json",
  "properties": {
    "Framework": {
      "description": "Determines what testing framework to use. This will override the other detection methods.",
      "type": "string",
      "enum": ["qunit", "jasmine", "mocha"]
    },
    "FrameworkVersion": {
      "description": "Tells Chutzpah if it should use a different version of on of the test frameworks than the default one. Currently, the only framework this works for is Jasmine. As of the 3.1.0 release Chutzpah default to Jasmine 2.0 but if you want to use the 1.0 line for Jasmine still pass '1' for FrameworkVersion.",
      "type": "string"
    },
    "References": {
      "description": "The references setting allows you to specify which files/folders to use/scan to find references. This is useful since it replaces the need to the ///<reference comments.",
      "type": "array",
      "items": {
        "$ref": "#/definitions/referenceSettings"
      }
    },
    "Tests": {
      "description": "The references setting allows you to specify which files/folders to use/scan to find references. This is useful since it replaces the need to the ///<reference comments.",
      "type": "array",
      "items": {
        "$ref": "#/definitions/testSettings"
      }
    },
    "Engine": {
      "description": "The browser engine to use to run the tests. Default is Phantom but JSDOM and Chrome are available. If you choose Chrome you must have an instance of Chrome or Chromium on the machine that Chutzpah can find.",
      "type": "string",
      "enum": ["Phantom", "JSDom", "Chrome"]
    },
    "EngineOptions": {
      "$ref": "#/definitions/engineOptions"
    },
    "Server": {
      "$ref": "#/definitions/serverSettings"
    },
    "Transforms": {
      "description": "List of transformers to run after testing to generate output files",
      "type": "array",
      "items": {
        "$ref": "#/definitions/transformConfig"
      }
    },
    "Compile": {
      "$ref": "#/definitions/compileSettings"
    },
    "TestFileTimeout": {
      "description": "The time to wait for tests in a file to finish in milliseconds.",
      "type": "integer"
    },
    "TestHarnessLocationMode": {
      "description": "Determines where to place the generated html test harness files. The default mode is TestFileAdjacent which means the harness is placed in the same directory as the test file. SettingsFileAdjacent means it is placed in the same directory as the chutzpah.json file. Custom mode lets you specify a custom path to the directory.",
      "type": "string",
      "enum": ["TestFileAdjacent", "SettingsFileAdjacent", "Custom"]
    },
    "TestHarnessReferenceMode": {
      "type": "string",
      "enum": ["Normal", "AMD"]
    },
    "TestHarnessDirectory": {
      "description": "When TestHarnessLocationMode is set to Custom this is either the relative or absolute path to the directory where to place the test harness.",
      "type": "string"
    },
    "RootReferencePathMode": {
      "description": "This property determines what directory a rooted reference path refers to.",
      "type": "string",
      "enum": ["DriveRoot", "SettingsFileDirectory"],
      "default": "DriveRoot"
    },
    "CodeCoverageTimeout": {
      "description": "The timeout in milliseconds for how long to wait to instrument each file for code coverage. Defaults to 5000ms.",
      "type": "integer",
      "default": 5000
    },
    "CodeCoverageExecutionMode": {
      "description": "If Always, forces code coverage to run always. If Manual/null/not set, allows code coverage to run if invoked using test adapter, command line or context menu options (default). If Never, forces code coverage to never run.",
      "type": "string",
      "enum": ["Manual", "Always", "Never"]
    },
    "CodeCoverageSuccessPercentage": {
      "description": "The percentage of lines needing to be covered to show the coverage output as success or failure. By default this is 60.",
      "type": "number"
    },
    "CodeCoverageIncludes": {
      "description": "The collection code coverage file patterns to include in coverage. These are in glob format. If you specify none all files are included.",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "CodeCoverageExcludes": {
      "description": "The collection code coverage file patterns to exclude in coverage. These are in glob format. If you specify none no files are excluded.",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "CustomTestHarnessPath": {
      "description": "The CustomTestHarnessPath setting allows you to override the default template Chutzpah uses for the HTML test harness. This is an advanced feature which should only be used as a last resort.",
      "type": "string"
    },
    "MochaInterface": {
      "description": "The name of the Mocha interface to use. Overrides the default detection mechanism.",
      "type": "string",
      "enum": ["bdd", "tdd", "qunit"]
    },
    "AMDBaseUrl": {
      "description": "Set the baseurl for Chutzpah to use when generating the test harness. Defaults to the test harness directory if not set.",
      "type": "string"
    },
    "AMDAppDirectory": {
      "description": "Sets the root directory for your AMD paths. This is only needed if your baseUrl is a different location than your source directory. This is common if you are compiling from another language to JavaScript and copying those compiled files to a different folder. For example if you have all your .ts files in /src and you compile them to a /out directory then your AMDBaseUrl is /out and AMDAppDirectory is /src. Defaults to the test harness directory if not set.",
      "type": "string"
    },
    "UserAgent": {
      "description": "The user agent to use when making web requests",
      "type": "string"
    },
    "TestPattern": {
      "description": "When Chutzpah reports test results it also tells you what line they are on. The way this is accomplished is by having a regex for each testing framework which describes where to find the names of your tests.",
      "type": "string",
      "format": "regex"
    },
    "EnableTestFileBatching": {
      "description": "Determines if batch all test files for this chutzpah.json file should be batched into one test harness. This will often make your test run much faster.",
      "type": "boolean"
    },
    "InheritFromParent": {
      "description": "Determines if this settings file should inherit and merge with the settings of its parent settings file. The parent is found by recursively walking up the tree.",
      "type": "boolean"
    },
    "IgnoreResourceLoadingErrors": {
      "description": "Suppress errors that are reported when a script request to load a url (e.g. xhr/script/image) fails.",
      "type": "boolean"
    },
    "EnableTracing": {
      "description": "Logs tracing information to a log file.",
      "type": "boolean"
    },
    "TraceFilePath": {
      "description": "The path to write the trace file to. Defaults tp %temp%/chutzpah.log.",
      "type": "string"
    },
    "Parallelism": {
      "description": "Max degree of parallelism for running tests. Defaults to number of CPUs",
      "type": "number"
    },
    "BrowserArguments": {
      "description": "The dictionary of browser name (keys) to corresponding browser arguments (values), i.e.; { 'chrome': '--allow-file-access-from-files' }.",
      "type": "object"
    }
  },
  "title": "JSON schema for Chutzpah test runner settings files",
  "type": "object"
}