Skip to content

Tests setting

Matthew Manela edited this page Sep 3, 2015 · 4 revisions

The tests setting allows you to specify which files/folders to use as test files. The tests setting section can be used in two ways: discovery or filtering.

For discovery you can tell chutzpah.console.exe to execute a chutzpah.json file. Chutzpah will evaluate the tests settings and use it to find all files it describes.

chutzpah.console.exe path/to/chutzpah.json

For filtering Chutzpah will skip test files which don’t match the tests setting. This is a much needed feature for the Visual Studio integration. By default the test adapter plugin will look at all *.js files and try to see if they are test files. Often Chutzpah is able to use heuristics to quickly tell if a file is a test file. If the heuristics fails it then needs to actually execute that file. This can be very slow especially if Chutzpah is doing this with a large JS library. With this tests setting feature you can help Chutzpah out by placing a chutzpah.json at the root of your project and indicate which files are the test files. This can be a big performance boost and is the recommendation for all projects.

Name Description
Path 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.
Includes This is an optional array of include glob patterns. This is used when the Path is a folder. Only files matching the Include pattern will be added.
Excludes This is an optional array of exclude glob patterns. This is used when the path is a folder. All files matching the exclude pattern will not be added.
ExpandReferenceComments This option (which default to false), indicates that you want Chutzpah to open the test file and search for reference comments (e.g. /// <reference).

Example:

This file shows a few different ways you can write the test settings.

{
    "Tests": [
        { "Includes": ["*test1*"] },
        { "Path": "Dir3/test.js"},
        { "Path": "Dir1", "Includes": ["*.js"], "Excludes": ["*test4.js"] },
        { "Path": "Dir2" }
    ]
}
  • Line #3 – Includes all tests that contain test1 in its path. This is in glob format.
  • Line #4 – Includes the file Dir3/test.js (relative to the chtuzpah.json path).
  • Line #5 – Includes all *.js files in the folder Dir1 except test4.js. (Include/Exclude in glob format)
  • Line #6 – Includes all files in Dir2