如何在当前项目中使用chutzpah

时间:2017-08-30 11:45:23

标签: node.js visual-studio typescript visual-studio-2012

我正在设置chutzpah和Jasmine,用打字稿对我的项目进行单元测试。

我已经使用npm安装了Jasmine但我很困惑如何将chutzpah包含在visual studio代码中。

我去了这个GitHub,但没有什么是我清楚的: -

https://github.com/mmanela/chutzpah

另外,我从以下来源下载了visual studio代码的文件: -

https://marketplace.visualstudio.com/items?itemName=vs-publisher-2795.ChutzpahTestRunnerContextMenuExtension

https://marketplace.visualstudio.com/items?itemName=vs-publisher-2795.ChutzpahTestAdapterfortheTestExplorer

当我尝试将以上下载的文件作为可视代码中的扩展加载时,我收到错误: -

在zip中找不到extension / package.json。

如何在我的项目中包含或安装chutzpah然后使用chutzpah.json文件?

提前致谢。

1 个答案:

答案 0 :(得分:2)

首先从命令行转到项目位置并执行:

npm init

这将创建package.json

比: chuzpah.json你可以手动创建并首先从Visual Studio运行并右键单击,如果你正确安装了插件,你会看到运行单元测试选项。 设置chutzpah.json是棘手的部分。  here is template for setup

{        
"Framework": "qunit|jasmine|mocha",

"FrameworkVersion": "",

"EnableTestFileBatching": "true|false",

"InheritFromParent": "true|false",

"InheritFromPtah": "<Path to another chutzpah.json>",

"IgnoreResourceLoadingErrors": "true|false"

"TestFileTimeout": "<Timeout in milliseconds>",

"TestHarnessLocationMode": "TestFileAdjacent|SettingsFileAdjacent|Custom",

"TestHarnessDirectory": "<Path to a folder>",

"TestHarnessReferenceMode": "Normal|AMD",

"RootReferencePathMode":"DriveRoot|SettingsFileDirectory",

"CodeCoverageIncludes": [],

"CodeCoverageExcludes": [],

"CodeCoverageIgnores": [],

"CodeCoverageExecutionMode": "Manual|Always|Never",

"CodeCoverageSuccessPercentage": <Number from 0 to 100>,

"CodeCoverageTimeout": <Timeout in milliseconds>

"References": [],

"Tests": [],

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

"Compile": <A compile configuration object>,

"Server": <A server configuration object>,

"TestPattern": "<Regex test name pattern>",

"AMDBaseUrl": "<Path to same location that your Require.js config baseurl points to>",

"AMDAppDirectory": "<The root folder for your AMD paths>",

"UserAgent": "<Custom user agent to use during testing>",

"Transforms": [],

"EnableTracing": true|false,

"TraceFilePath": "<Path to log file. Defaults to %temp%/chutzpah.log>",

"Parallelism": "<Max degree of parallelism for Chutzpah. Defaults to number of CPUs>",

"BrowserArguments": <A map of browser name (keys) to corresponding browser arguments (values), i.e.; { 'chrome': '--allow-file-access-from-files' }.>
}

毕竟,您可以使用commang line和Chutzpah runner来运行单元测试作为CI的一部分