Quantcast
Channel: Chutzpah - A JavaScript Test Runner
Viewing all 1864 articles
Browse latest View live

New Post: Debugging TypeScript in browser using source maps

$
0
0
Will do. Thanks for the prompt reply!

Walter

New Post: Open in browser leaves temporary files around

$
0
0
I don't understand what problem these files being there presents though. If you are working in TypeScript the compilation has to happen at some point. And if you are running Chutzpah on top of them it would need to run again to pick up the changes. I am not sure this issue has anything to do with Chutzpah putting those files in place. If Chutzpah placed its files in a separate folder it wouldn't make this any better.

Source code checked in, #62514114c508aaaf2f88b1d3598294c503d82d6a

Created Unassigned: Ability to debug TypeScript source in browser [181]

$
0
0
When using the "Open in browser" menu extension on a TypeScript file, Chutzpah automatically generates javascript files that it uses to execute the unit tests. While these raw javascript files can be used in a browser's debugger, the original TypeScript sources cannot. This may because the generated javascript file does not have the comment that allows the browser to find an associated source map file (i.e. "//# sourceMappingURL=typescriptsource.js.map").

Commented Unassigned: Ability to debug TypeScript source in browser [181]

$
0
0
When using the "Open in browser" menu extension on a TypeScript file, Chutzpah automatically generates javascript files that it uses to execute the unit tests. While these raw javascript files can be used in a browser's debugger, the original TypeScript sources cannot. This may because the generated javascript file does not have the comment that allows the browser to find an associated source map file (i.e. "//# sourceMappingURL=typescriptsource.js.map").
Comments: Thanks for suggesting this feature. I definitely would like to add this in a future release. The next version is already feature complete but will target it for a release after that.

Edited Feature: Ability to debug TypeScript source in browser [181]

$
0
0
When using the "Open in browser" menu extension on a TypeScript file, Chutzpah automatically generates javascript files that it uses to execute the unit tests. While these raw javascript files can be used in a browser's debugger, the original TypeScript sources cannot. This may because the generated javascript file does not have the comment that allows the browser to find an associated source map file (i.e. "//# sourceMappingURL=typescriptsource.js.map").

Source code checked in, #bd2597346031df243742160babb2c89f48029647

Updated Release: Chutzpah 3.0.0 (Dec 12, 2013)

$
0
0
3.0.0
  • Improved RequireJS support
  • Mocha Test Framework support
  • Customizable HTML harness generation
  • Command line failure report flag
  • Chutzpah.json additions
  • Upgrading to TypeScript 0.9.5.0
  • Improved logging integrated into VS Plugins
  • Fix VS 2013 compatibility issues

Released: Chutzpah 2.5.0 (Aug 31, 2013)

$
0
0
2.5.0
  • Added support for VS 2013
  • Added initial tracing support
  • Treat path that start with ~/ as the same as a path that start with /. This can be used with the RootReferencePathMode settings to get consistent behavior between Chutzpah and ASP.NET.
  • Fix bug in timeout detection where logging events would keep Chutzpah form detecting a hung test case.
  • Print log messages to console. They were suppressed formerly.

Updated Release: Chutzpah 2.5.0 (Aug 31, 2013)

$
0
0
2.5.0
  • Added support for VS 2013
  • Added initial tracing support
  • Treat path that start with ~/ as the same as a path that start with /. This can be used with the RootReferencePathMode settings to get consistent behavior between Chutzpah and ASP.NET.
  • Fix bug in timeout detection where logging events would keep Chutzpah form detecting a hung test case.
  • Print log messages to console. They were suppressed formerly.

Updated Wiki: Home

$
0
0

Welcome to Chutzpah - A JavaScript Test Runner

Pronunciation: hutz·pah

Chutzpah is an open source JavaScript test runner which helps you integrate JavaScript unit testing into your website. It enables you to run JavaScript unit tests from the command line and from inside of Visual Studio. It also supports running in the TeamCity continuous integration server.

For comments, praise, complaints you can reach me on twitter at @mmanela

Chutzpah supports the QUnit, Jasmine and Mocha testing frameworks.
Chutzpah uses the PhantomJS headless browser to run your tests.


Notice: Known issue and workaround if you have both NVidia and Intel video drivers

Recent News

Quick Downloads

Contents

  1. What do I need to use this?
  2. What can Chutzpah do?
  3. How do I use Chutzpah?
  4. How can I use it with CoffeeScript?
  5. How to build the code?
  6. How can I contribute to this project?

Requirements

General
Visual Studio integration
  • Visual Studio 2010
  • Visual Studio 2012 Update 3
  • Visual Studio 2013

Features

Runs JavaScript unit tests from the command line

commandLine.png


Run JavaScript unit tests from inside of Visual Studio

  • Right click menu to run tests
contextmenu.png

  • Shows test results in Error window
errorWindow.png

  • Shows test results in Ouput window
outputWindow.png

  • Integrates into VS 2012 Unit Test Explorer
UnitTestExplorer.png

Updated Wiki: Home

$
0
0

Welcome to Chutzpah - A JavaScript Test Runner

Pronunciation: hutz·pah

Chutzpah is an open source JavaScript test runner which helps you integrate JavaScript unit testing into your website. It enables you to run JavaScript unit tests from the command line and from inside of Visual Studio. It also supports running in the TeamCity continuous integration server.

For comments, praise, complaints you can reach me on twitter at @mmanela

Chutzpah supports the QUnit, Jasmine and Mocha testing frameworks.
Chutzpah uses the PhantomJS headless browser to run your tests.


Notice: Known issue and workaround if you have both NVidia and Intel video drivers

Recent News

Quick Downloads

Contents

  1. What do I need to use this?
  2. What can Chutzpah do?
  3. How do I use Chutzpah?
  4. How can I use it with CoffeeScript?
  5. How to build the code?
  6. How can I contribute to this project?

Requirements

General
Visual Studio integration
  • Visual Studio 2010
  • Visual Studio 2012 Update 3
  • Visual Studio 2013

Features

Runs JavaScript unit tests from the command line

commandLine.png


Run JavaScript unit tests from inside of Visual Studio

  • Right click menu to run tests
contextmenu.png

  • Shows test results in Error window
errorWindow.png

  • Shows test results in Ouput window
outputWindow.png

  • Integrates into VS 2012 Unit Test Explorer
UnitTestExplorer.png

Updated Wiki: Command Line Options

$
0
0
Chutzpah console test runner (64-bit .NET 4.0.30319.34003)
Copyright (C) 2013 Matthew Manela (http://matthewmanela.com).

usage: chutzpah.console [options]
usage: chutzpah.console <testFile> [options]

Valid options:
  /silent                : Do not output running test count
  /teamcity              : Forces TeamCity mode (normally auto-detected)
  /wait                  : Wait for input after completion
  /failOnError           : Return a non-zero exit code if any script errors or timeouts occurs
  /failOnScriptError     : Alias for failOnError (deprecated)
  /debug                 : Print debugging information and tracing to console
  /trace                 : Logs tracing information to chutzpah.log
  /openInBrowser         : Launch the tests in the default browser
  /timeoutMilliseconds   : Amount of time to wait for a test file to finish before failing. (Defaults to 5000)
  /parallelism [n]       : Max degree of parallelism for Chutzpah. Defaults to number of CPUs + 1
                         : If you specify more than 1 the test output may be a bit jumbled
  /path path             : Adds a path to a folder or file to the list of test paths to run.
                         : Specify more than one to add multiple paths.
                         : If you give a folder, it will be scanned for testable files.
                         : (e.g. /path test1.html /path testFolder)
  /file path             : Alias for /path (deprecated)
  /vsoutput              : Print output in a format that the VS error list recognizes
  /coverage              : Enable coverage collection
  /coverageIncludes pat  : Only instrument files that match the given shell patterns (in glob format), comma separated.
  /coverageExcludes pat  : Don't instrument files that match the given shell pattern (in glob format), comma separated.
  /compilercachefile     : File where compiled scripts can be cached. Defaults to a file in the temp directory.
  /compilercachesize     : The maximum size of the cache in Mb. Defaults to 32Mb.
  /testMode              : The mode to test in (All, Html, AllExceptHTML, TypeScript, CoffeeScript, JavaScript)
  /showFailureReport     : Show a failure report after the test run. Usefull if you have a large number of tests.
  /junit filename        : output results to JUnit-style XML file

Updated Wiki: Chutzpah.json Settings File

$
0
0

Using the Chutzpah.json Settings File

The Chutzpah settings file is an .json file that you can place anywhere in your testing directories to inform Chutzpah of test specific settings. The Chuzpah settings file is completely optional and if the file or any of its properties are omitted Chutzpah will use the default values.

When Chutzpah is run on a file (lets say test.js) it scans the current directory for a file named chutzpah.json. If it does not find one it will recursively traverse up the directory chain looking for one. This behavior provides a lot of flexibility since you can provide multiple chutzpah.json files in your tree and each one will work over its sub-folder. This lets you have different settings for different groups of tests.

The settings file is a text file with json content of the following format:

{
    "Framework": "qunit|jasmine|mocha",
    
    "TestFileTimeout": "<Timeout in milliseconds>",
    
    "TestHarnessLocationMode": "TestFileAdjacent|SettingsFileAdjacent|Custom",
    
    "TestHarnessDirectory": "<Path to a folder>",

    "TestHarnessReferenceMode": "Normal|AMD",

    "TypeScriptCodeGenTarget" : "ES3|ES5",

    "TypeScriptModuleKind" : "CommonJS|AMD",
    
    "RootReferencePathMode":"DriveRoot|SettingsFileDirectory",
    
    "CodeCoverageIncludes": [],
    
    "CodeCoverageExcludes": [],

    "EnableCodeCoverage": "true|false",

    "References": [],

    "CustomTestHarnessPath": "<Path to custom test harness file>"

    
}

The chutzpah.json file supports the following properties

Framework– Determines what testing framework to use. This will override the other detection methods. This is helpful if Chutzpah is having trouble figuring out what your intended framework is. If left out Chutzpah will automatically try to detect the framework.

TestFileTimeout - The time to wait for tests in a file to finish in milliseconds

TestHarnessLocationMode– 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.

TestHarnessDirectory– When TestHarnessLocationMode is set to Custom this is either the relative or absolute path to the directory where to place the test harness.

TypeScriptCodeGenTarget– When running on a TypeScript file this property will tell the TypeScript compiler what type of code to generate. ES3 is for ECMAScript 3 and ES5 is for ECMAScript 5.

RootReferencePathMode– This property determines what directory a rooted reference path refers to. In a test file Chutzpah parses the <reference path="" /> tags to determine your test dependencies. By default (the DriveRoot setting) if you write <reference path="\a.js" /> Chutzpah will look for a.js under C:\ (assuming you are running your test in the C drive). However, if you set this property to SettingsFileDirectory Chutpah will now look for a.js relative to the location of the chutzpah.json file. This is useful if you have a large project and want to minimize the number of long reference paths.

CodeCoverageIncludes - The collection code coverage file patterns to include in coverage. These are in glob format. If you specify none all files are included.

CodeCoverageExcludes - The collection code coverage file patterns to exclude in coverage. These are in glob format. If you specify none no files are excluded.



Examples:
This file tells Chutzpah to use QUnit and to place the test harness next to the chutzpah.json file:
{
    "Framework": "qunit",
    "TestHarnessLocationMode": "SettingsFileAdjacent"
}

This file tells Chutzpah to convert TypeScript to ES5 code and to place the test harness in a custom directory:
{
    "TypeScriptCodeGenTarget" : "ES5",
    "TestHarnessLocationMode": "Custom",
    "TestHarnessDirectory": "../Some/Folder"
}

When run with Code Coverage this file tells Chutzpah to exclude files named jquery.js and include files that have a suffix of query.js or are named dogs.js:
{
    "CodeCoverageExcludes": ["*\\jquery.js"],
    "CodeCoverageIncludes": ["*query.js", "*\\dog.js"]
} 

Updated Wiki: Chutzpah.json Settings File

$
0
0

Using the Chutzpah.json Settings File

The Chutzpah settings file is an .json file that you can place anywhere in your testing directories to inform Chutzpah of test specific settings. The Chuzpah settings file is completely optional and if the file or any of its properties are omitted Chutzpah will use the default values.

When Chutzpah is run on a file (lets say test.js) it scans the current directory for a file named chutzpah.json. If it does not find one it will recursively traverse up the directory chain looking for one. This behavior provides a lot of flexibility since you can provide multiple chutzpah.json files in your tree and each one will work over its sub-folder. This lets you have different settings for different groups of tests.

The settings file is a text file with json content of the following format:

{
    "Framework": "qunit|jasmine|mocha",
    
    "TestFileTimeout": "<Timeout in milliseconds>",
    
    "TestHarnessLocationMode": "TestFileAdjacent|SettingsFileAdjacent|Custom",
    
    "TestHarnessDirectory": "<Path to a folder>",

    "TestHarnessReferenceMode": "Normal|AMD",

    "TypeScriptCodeGenTarget" : "ES3|ES5",

    "TypeScriptModuleKind" : "CommonJS|AMD",
    
    "RootReferencePathMode":"DriveRoot|SettingsFileDirectory",
    
    "CodeCoverageIncludes": [],
    
    "CodeCoverageExcludes": [],

    "EnableCodeCoverage": "true|false",

    "References": [],

    "CustomTestHarnessPath": "<Path to custom test harness file>"

}

The chutzpah.json file supports the following properties

Framework– Determines what testing framework to use. This will override the other detection methods. This is helpful if Chutzpah is having trouble figuring out what your intended framework is. If left out Chutzpah will automatically try to detect the framework.

TestFileTimeout - The time to wait for tests in a file to finish in milliseconds

TestHarnessLocationMode– 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.

TestHarnessDirectory– When TestHarnessLocationMode is set to Custom this is either the relative or absolute path to the directory where to place the test harness.

TypeScriptCodeGenTarget– When running on a TypeScript file this property will tell the TypeScript compiler what type of code to generate. ES3 is for ECMAScript 3 and ES5 is for ECMAScript 5.

RootReferencePathMode– This property determines what directory a rooted reference path refers to. In a test file Chutzpah parses the <reference path="" /> tags to determine your test dependencies. By default (the DriveRoot setting) if you write <reference path="\a.js" /> Chutzpah will look for a.js under C:\ (assuming you are running your test in the C drive). However, if you set this property to SettingsFileDirectory Chutpah will now look for a.js relative to the location of the chutzpah.json file. This is useful if you have a large project and want to minimize the number of long reference paths.

CodeCoverageIncludes - The collection code coverage file patterns to include in coverage. These are in glob format. If you specify none all files are included.

CodeCoverageExcludes - The collection code coverage file patterns to exclude in coverage. These are in glob format. If you specify none no files are excluded.



Examples:
This file tells Chutzpah to use QUnit and to place the test harness next to the chutzpah.json file:
{
    "Framework": "qunit",
    "TestHarnessLocationMode": "SettingsFileAdjacent"
}

This file tells Chutzpah to convert TypeScript to ES5 code and to place the test harness in a custom directory:
{
    "TypeScriptCodeGenTarget" : "ES5",
    "TestHarnessLocationMode": "Custom",
    "TestHarnessDirectory": "../Some/Folder"
}

When run with Code Coverage this file tells Chutzpah to exclude files named jquery.js and include files that have a suffix of query.js or are named dogs.js:
{
    "CodeCoverageExcludes": ["*\\jquery.js"],
    "CodeCoverageIncludes": ["*query.js", "*\\dog.js"]
} 

Updated Wiki: Chutzpah.json Settings File

$
0
0

Using the Chutzpah.json Settings File

The Chutzpah settings file is an .json file that you can place anywhere in your testing directories to inform Chutzpah of test specific settings. The Chuzpah settings file is completely optional and if the file or any of its properties are omitted Chutzpah will use the default values.

When Chutzpah is run on a file (lets say test.js) it scans the current directory for a file named chutzpah.json. If it does not find one it will recursively traverse up the directory chain looking for one. This behavior provides a lot of flexibility since you can provide multiple chutzpah.json files in your tree and each one will work over its sub-folder. This lets you have different settings for different groups of tests.

The settings file is a text file with json content of the following format:

{
    "Framework": "qunit|jasmine|mocha",
    
    "TestFileTimeout": "<Timeout in milliseconds>",
    
    "TestHarnessLocationMode": "TestFileAdjacent|SettingsFileAdjacent|Custom",
    
    "TestHarnessDirectory": "<Path to a folder>",

    "TestHarnessReferenceMode": "Normal|AMD",

    "TypeScriptCodeGenTarget" : "ES3|ES5",

    "TypeScriptModuleKind" : "CommonJS|AMD",
    
    "RootReferencePathMode":"DriveRoot|SettingsFileDirectory",
    
    "CodeCoverageIncludes": [],
    
    "CodeCoverageExcludes": [],

    "EnableCodeCoverage": "true|false",

    "References": [],

    "CustomTestHarnessPath": "<Path to custom test harness file>"

}

The chutzpah.json file supports the following properties

Framework– Determines what testing framework to use. This will override the other detection methods. This is helpful if Chutzpah is having trouble figuring out what your intended framework is. If left out Chutzpah will automatically try to detect the framework.

TestFileTimeout - The time to wait for tests in a file to finish in milliseconds

TestHarnessLocationMode– 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.

TestHarnessDirectory– When TestHarnessLocationMode is set to Custom this is either the relative or absolute path to the directory where to place the test harness.

TypeScriptCodeGenTarget– When running on a TypeScript file this property will tell the TypeScript compiler what type of code to generate. ES3 is for ECMAScript 3 and ES5 is for ECMAScript 5.

RootReferencePathMode– This property determines what directory a rooted reference path refers to. In a test file Chutzpah parses the <reference path="" /> tags to determine your test dependencies. By default (the DriveRoot setting) if you write <reference path="\a.js" /> Chutzpah will look for a.js under C:\ (assuming you are running your test in the C drive). However, if you set this property to SettingsFileDirectory Chutpah will now look for a.js relative to the location of the chutzpah.json file. This is useful if you have a large project and want to minimize the number of long reference paths.

CodeCoverageIncludes - The collection code coverage file patterns to include in coverage. These are in glob format. If you specify none all files are included.

CodeCoverageExcludes - The collection code coverage file patterns to exclude in coverage. These are in glob format. If you specify none no files are excluded.

References - 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. This setting is a list of path entries each which can contain the following arguments:

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.
Include This is an optional include glob pattern. This is used when the Path is a folder. Only files matching the Include pattern will be added.
Exclude This is an optional exclude glob pattern. This is used when the path is a folder. All files matching the exclude pattern will not be added.
IncludeInTestHarness 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.
IsTestFrameworkFile Indicated that this references should be placed directly after the test framework files (like QUnit.js) in the test harness. This ensures that this file is injected into the test harness before almost all other files. Defaults to false.


Examples:
This file tells Chutzpah to use QUnit and to place the test harness next to the chutzpah.json file:
{
    "Framework": "qunit",
    "TestHarnessLocationMode": "SettingsFileAdjacent"
}

This file tells Chutzpah to convert TypeScript to ES5 code and to place the test harness in a custom directory:
{
    "TypeScriptCodeGenTarget" : "ES5",
    "TestHarnessLocationMode": "Custom",
    "TestHarnessDirectory": "../Some/Folder"
}

When run with Code Coverage this file tells Chutzpah to exclude files named jquery.js and include files that have a suffix of query.js or are named dogs.js:
{
    "CodeCoverageExcludes": ["*\\jquery.js"],
    "CodeCoverageIncludes": ["*query.js", "*\\dog.js"]
} 

Updated Wiki: Chutzpah.json Settings File

$
0
0

Using the Chutzpah.json Settings File

The Chutzpah settings file is an .json file that you can place anywhere in your testing directories to inform Chutzpah of test specific settings. The Chuzpah settings file is completely optional and if the file or any of its properties are omitted Chutzpah will use the default values.

When Chutzpah is run on a file (lets say test.js) it scans the current directory for a file named chutzpah.json. If it does not find one it will recursively traverse up the directory chain looking for one. This behavior provides a lot of flexibility since you can provide multiple chutzpah.json files in your tree and each one will work over its sub-folder. This lets you have different settings for different groups of tests.

The settings file is a text file with json content of the following format:

{
    "Framework": "qunit|jasmine|mocha",
    
    "TestFileTimeout": "<Timeout in milliseconds>",
    
    "TestHarnessLocationMode": "TestFileAdjacent|SettingsFileAdjacent|Custom",
    
    "TestHarnessDirectory": "<Path to a folder>",

    "TestHarnessReferenceMode": "Normal|AMD",

    "TypeScriptCodeGenTarget" : "ES3|ES5",

    "TypeScriptModuleKind" : "CommonJS|AMD",
    
    "RootReferencePathMode":"DriveRoot|SettingsFileDirectory",
    
    "CodeCoverageIncludes": [],
    
    "CodeCoverageExcludes": [],

    "EnableCodeCoverage": "true|false",

    "References": [],

    "CustomTestHarnessPath": "<Path to custom test harness file>"

}

The chutzpah.json file supports the following properties

Framework– Determines what testing framework to use. This will override the other detection methods. This is helpful if Chutzpah is having trouble figuring out what your intended framework is. If left out Chutzpah will automatically try to detect the framework.

TestFileTimeout - The time to wait for tests in a file to finish in milliseconds

TestHarnessLocationMode– 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.

TestHarnessDirectory– When TestHarnessLocationMode is set to Custom this is either the relative or absolute path to the directory where to place the test harness.

TypeScriptCodeGenTarget– When running on a TypeScript file this property will tell the TypeScript compiler what type of code to generate. ES3 is for ECMAScript 3 and ES5 is for ECMAScript 5.

RootReferencePathMode– This property determines what directory a rooted reference path refers to. In a test file Chutzpah parses the <reference path="" /> tags to determine your test dependencies. By default (the DriveRoot setting) if you write <reference path="\a.js" /> Chutzpah will look for a.js under C:\ (assuming you are running your test in the C drive). However, if you set this property to SettingsFileDirectory Chutpah will now look for a.js relative to the location of the chutzpah.json file. This is useful if you have a large project and want to minimize the number of long reference paths.

CodeCoverageIncludes - The collection code coverage file patterns to include in coverage. These are in glob format. If you specify none all files are included.

CodeCoverageExcludes - The collection code coverage file patterns to exclude in coverage. These are in glob format. If you specify none no files are excluded.

References - 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. This setting is a list of path entries each which can contain the following arguments:

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.
Include This is an optional include glob pattern. This is used when the Path is a folder. Only files matching the Include pattern will be added.
Exclude This is an optional exclude glob pattern. This is used when the path is a folder. All files matching the exclude pattern will not be added.
IncludeInTestHarness 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.
IsTestFrameworkFile Indicated that this references should be placed directly after the test framework files (like QUnit.js) in the test harness. This ensures that this file is injected into the test harness before almost all other files. Defaults to false.

Examples:

This file tells Chutzpah to use QUnit and to place the test harness next to the chutzpah.json file:
{
    "Framework": "qunit",
    "TestHarnessLocationMode": "SettingsFileAdjacent"
}

This file tells Chutzpah to convert TypeScript to ES5 code and to place the test harness in a custom directory:
{
    "TypeScriptCodeGenTarget" : "ES5",
    "TestHarnessLocationMode": "Custom",
    "TestHarnessDirectory": "../Some/Folder"
}

When run with Code Coverage this file tells Chutzpah to exclude files named jquery.js and include files that have a suffix of query.js or are named dogs.js:
{
    "CodeCoverageExcludes": ["*\\jquery.js"],
    "CodeCoverageIncludes": ["*query.js", "*\\dog.js"]
} 

Updated Wiki: Chutzpah.json Settings File

$
0
0

Using the Chutzpah.json Settings File

The Chutzpah settings file is an .json file that you can place anywhere in your testing directories to inform Chutzpah of test specific settings. The Chuzpah settings file is completely optional and if the file or any of its properties are omitted Chutzpah will use the default values.

When Chutzpah is run on a file (lets say test.js) it scans the current directory for a file named chutzpah.json. If it does not find one it will recursively traverse up the directory chain looking for one. This behavior provides a lot of flexibility since you can provide multiple chutzpah.json files in your tree and each one will work over its sub-folder. This lets you have different settings for different groups of tests.

The settings file is a text file with json content of the following format:

{
    "Framework": "qunit|jasmine|mocha",
    
    "TestFileTimeout": "<Timeout in milliseconds>",
    
    "TestHarnessLocationMode": "TestFileAdjacent|SettingsFileAdjacent|Custom",
    
    "TestHarnessDirectory": "<Path to a folder>",

    "TestHarnessReferenceMode": "Normal|AMD",

    "TypeScriptCodeGenTarget" : "ES3|ES5",

    "TypeScriptModuleKind" : "CommonJS|AMD",
    
    "RootReferencePathMode":"DriveRoot|SettingsFileDirectory",
    
    "CodeCoverageIncludes": [],
    
    "CodeCoverageExcludes": [],

    "EnableCodeCoverage": "true|false",

    "References": [],

    "CustomTestHarnessPath": "<Path to custom test harness file>"

}

The chutzpah.json file supports the following properties

Framework– Determines what testing framework to use. This will override the other detection methods. This is helpful if Chutzpah is having trouble figuring out what your intended framework is. If left out Chutzpah will automatically try to detect the framework.

TestFileTimeout - The time to wait for tests in a file to finish in milliseconds

TestHarnessLocationMode– 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.

TestHarnessDirectory– When TestHarnessLocationMode is set to Custom this is either the relative or absolute path to the directory where to place the test harness.

TypeScriptCodeGenTarget– When running on a TypeScript file this property will tell the TypeScript compiler what type of code to generate. ES3 is for ECMAScript 3 and ES5 is for ECMAScript 5.

RootReferencePathMode– This property determines what directory a rooted reference path refers to. In a test file Chutzpah parses the <reference path="" /> tags to determine your test dependencies. By default (the DriveRoot setting) if you write <reference path="\a.js" /> Chutzpah will look for a.js under C:\ (assuming you are running your test in the C drive). However, if you set this property to SettingsFileDirectory Chutpah will now look for a.js relative to the location of the chutzpah.json file. This is useful if you have a large project and want to minimize the number of long reference paths.

CodeCoverageIncludes - The collection code coverage file patterns to include in coverage. These are in glob format. If you specify none all files are included.

CodeCoverageExcludes - The collection code coverage file patterns to exclude in coverage. These are in glob format. If you specify none no files are excluded.

References - 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. This setting is a list of path entries each which can contain the following arguments:

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.
Include This is an optional include glob pattern. This is used when the Path is a folder. Only files matching the Include pattern will be added.
Exclude This is an optional exclude glob pattern. This is used when the path is a folder. All files matching the exclude pattern will not be added.
IncludeInTestHarness 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.
IsTestFrameworkFile Indicated that this references should be placed directly after the test framework files (like QUnit.js) in the test harness. This ensures that this file is injected into the test harness before almost all other files. Defaults to false.

Examples:

This file tells Chutzpah to use QUnit and to place the test harness next to the chutzpah.json file:
{
    "Framework": "qunit",
    "TestHarnessLocationMode": "SettingsFileAdjacent"
}

This file tells Chutzpah to convert TypeScript to ES5 code and to place the test harness in a custom directory:
{
    "TypeScriptCodeGenTarget" : "ES5",
    "TestHarnessLocationMode": "Custom",
    "TestHarnessDirectory": "../Some/Folder"
}

When run with Code Coverage this file tells Chutzpah to exclude files named jquery.js and include files that have a suffix of query.js or are named dogs.js:
{
    "CodeCoverageExcludes": ["*\\jquery.js"],
    "CodeCoverageIncludes": ["*query.js", "*\\dog.js"]
} 

Include files named a.js and b.js
{
    "References": [
        { "Path": "../a.js" },
        { "Path": "b.js"}
    ]
}

Include all .js files in a folder unless their name contains the word Resource
{
    "References": [
        { "Path": "src/Code", "Include": "*.js", "Exclude": "*Resource*" }
    ]
}

Updated Wiki: Chutzpah.json Settings File

$
0
0

Using the Chutzpah.json Settings File

The Chutzpah settings file is an .json file that you can place anywhere in your testing directories to inform Chutzpah of test specific settings. The Chuzpah settings file is completely optional and if the file or any of its properties are omitted Chutzpah will use the default values.

When Chutzpah is run on a file (lets say test.js) it scans the current directory for a file named chutzpah.json. If it does not find one it will recursively traverse up the directory chain looking for one. This behavior provides a lot of flexibility since you can provide multiple chutzpah.json files in your tree and each one will work over its sub-folder. This lets you have different settings for different groups of tests.

The settings file is a text file with json content of the following format:

{
    "Framework": "qunit|jasmine|mocha",
    
    "TestFileTimeout": "<Timeout in milliseconds>",
    
    "TestHarnessLocationMode": "TestFileAdjacent|SettingsFileAdjacent|Custom",
    
    "TestHarnessDirectory": "<Path to a folder>",

    "TestHarnessReferenceMode": "Normal|AMD",

    "TypeScriptCodeGenTarget" : "ES3|ES5",

    "TypeScriptModuleKind" : "CommonJS|AMD",
    
    "RootReferencePathMode":"DriveRoot|SettingsFileDirectory",
    
    "CodeCoverageIncludes": [],
    
    "CodeCoverageExcludes": [],

    "EnableCodeCoverage": "true|false",

    "References": [],

    "CustomTestHarnessPath": "<Path to custom test harness file>"

}

The chutzpah.json file supports the following properties

Framework– Determines what testing framework to use. This will override the other detection methods. This is helpful if Chutzpah is having trouble figuring out what your intended framework is. If left out Chutzpah will automatically try to detect the framework.

TestFileTimeout - The time to wait for tests in a file to finish in milliseconds

TestHarnessLocationMode– 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.

TestHarnessDirectory– When TestHarnessLocationMode is set to Custom this is either the relative or absolute path to the directory where to place the test harness.

TypeScriptCodeGenTarget– When running on a TypeScript file this property will tell the TypeScript compiler what type of code to generate. ES3 is for ECMAScript 3 and ES5 is for ECMAScript 5.

RootReferencePathMode– This property determines what directory a rooted reference path refers to. In a test file Chutzpah parses the <reference path="" /> tags to determine your test dependencies. By default (the DriveRoot setting) if you write <reference path="\a.js" /> Chutzpah will look for a.js under C:\ (assuming you are running your test in the C drive). However, if you set this property to SettingsFileDirectory Chutpah will now look for a.js relative to the location of the chutzpah.json file. This is useful if you have a large project and want to minimize the number of long reference paths.

CodeCoverageIncludes - The collection code coverage file patterns to include in coverage. These are in glob format. If you specify none all files are included.

CodeCoverageExcludes - The collection code coverage file patterns to exclude in coverage. These are in glob format. If you specify none no files are excluded.

References - 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. This setting is a list of path entries each which can contain the following arguments:

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.
Include This is an optional include glob pattern. This is used when the Path is a folder. Only files matching the Include pattern will be added.
Exclude This is an optional exclude glob pattern. This is used when the path is a folder. All files matching the exclude pattern will not be added.
IncludeInTestHarness 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.
IsTestFrameworkFile Indicated that this references should be placed directly after the test framework files (like QUnit.js) in the test harness. This ensures that this file is injected into the test harness before almost all other files. Defaults to false.

Examples:

This file tells Chutzpah to use QUnit and to place the test harness next to the chutzpah.json file:
{
    "Framework": "qunit",
    "TestHarnessLocationMode": "SettingsFileAdjacent"
}

This file tells Chutzpah to convert TypeScript to ES5 code and to place the test harness in a custom directory:
{
    "TypeScriptCodeGenTarget" : "ES5",
    "TestHarnessLocationMode": "Custom",
    "TestHarnessDirectory": "../Some/Folder"
}

When run with Code Coverage this file tells Chutzpah to exclude files named jquery.js and include files that have a suffix of query.js or are named dogs.js:
{
    "CodeCoverageExcludes": ["*\\jquery.js"],
    "CodeCoverageIncludes": ["*query.js", "*\\dog.js"]
} 

Include files named a.js and b.js:
{
    "References": [
        { "Path": "../a.js" },
        { "Path": "b.js"}
    ]
}

Include all .js files in a folder unless their name contains the word Resource:
{
    "References": [
        { "Path": "src/Code", "Include": "*.js", "Exclude": "*Resource*" }
    ]
}

Updated Wiki: Chutzpah File References

$
0
0

Chutzpah File References

One of the most important steps to having Chutzpah successfully run your tests is to set up your file references correctly. You accomplish this in two ways. One is adding a special file reference comment at the top of your files:

/// <reference path="someDependency.js" />

When Chutzpah sees this it will include that file in the generated test harness as well as recursively scan that file to find all of its references.

If you want to include a whole directory of files you can just specify a folder:

/// <reference path="some/folder" />

Chutzpah will the recursively scan that folder to find all references.

The other way to add references is using the references setting in the Chutzpah.json Settings File:

{
    "References": [
        { "Path": "someDependency.js" },
        { "Path": "some/folder", "Include": "*.js", "Exclude": "*Resource*" }
    ]
}

Excluding References

The reference syntax is also used by VS to give intellisense in JS files. This leads to an issue since sometimes you may reference a version of a file just for intellisense but you do not want Chutzpah to copy it. In this case you can include the chutzpah-exclude attribute to have it ignored by Chutzpah:

/// <reference path="someDependency.js" chutzpah-exclude="true" />

Alternate Reference Syntax

The reference syntax is also used by the TypeScript compiler for referencing files. This can cause an issue since Chutzpah expects you to reference your implementation files and TypeScript excepts you to reference your definition files. To mitigate this issue you can use a Chutzpah specific version of the reference command:

/// <chutzpah_reference path="someDependency.js" />

This works the same as the other syntax except that TypeScript (and VS) will ignore it.

Root Reference Path Mode

If you write a reference path like
/// <reference path="someDependency.js" />
then Chutzpah searched for that dependency relative to the current file. However, you can also specify a reference path like

/// <reference path="/someDependency.js" />

The beginning forward slash will tell Chutzpah to find that file at the root of the drive the file is in (e.g C:\). This behavior is configurable using a chutpah.json file. For example if you want the rooted reference path to be relative to a different directory you can place the a chutzpah.json file in that directory with the following content:

{
    "RootReferencePathMode":"SettingsFileDirectory"
}

Click this link to lean more of the Chutzpah.json Settings File


Viewing all 1864 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>