2016-05-15 14 views
1

JasmineChutzpahを使用してTypeScriptテストの最も基本的なテストを実行しようとしていますが、動作させることができません。ここでは、ソースファイルされる:シンプルなTypeScriptでChutzpahが動作しないテスト

class Simple { 
    public easyTest() { 
     return 5; 
    } 
} 

ここでは、仕様です:

/// <reference path="../../../scripts/typings/jasmine/jasmine.d.ts" /> 
/// <reference path="../../../src/typescript/classSimple.ts" /> 
describe("Simple Calculations",() => { 
    it("should return true",() => { 
     var simpl = new Simple(); 
     expect(simpl.easyTest()).toBe(5); 
    }); 
}); 

ここに私のchutzpah.jsonファイルされる:

{ 
    "RootReferencePathMode": "SettingsFileDirectory", 
    "Framework": "jasmine", 
    "Compile": { 
     "Mode": "External", 
     "Extensions": [ ".ts" ], 
     "ExtensionsWithNoOutput": [ ".d.ts" ] 
    }, 
    "References": [   
     { "Path": "../../../src/typescript/classSimple.ts" }   
    ], 
    "Tests": [ 
     { "Path": "simpleSpec.ts" } 
    ], 
    "EnableTracing": true 
} 

ここでは、フォルダ構造が

TestProject.sln 
-src 
--typescript 
---classSimple.ts 
-tests 
--jasmine 
---typescript 
----chutzpah.json 
----simpleSpec.ts 

ですこのVS.NET p rojectは保存時にTypeScriptをコンパイルするように設定されています。実際には、classSimple.tsと全く同じディレクトリに、JavaScript出力:classSimple.jsを物理的に見ています。 - それだけで終わりに遮断し、何も起こりません

Message:Chutzpah run started in mode Execution with parallelism set to 4 Message:Building test context for C:\dev\TestProject\tests\jasmine\typescript\simpleSpec.ts Message:Building test context for 'C:\dev\TestProject\tests\jasmine\typescript\simpleSpec.ts' Message:Test file c:\dev\TestProject\tests\jasmine\typescript\simplespec.ts matched test file path from settings file Message:Investigating reference file path '../../../src/typescript/classSimple.ts' Message:Added file 'C:\dev\TestProject\src\typescript\classSimple.ts' to referenced files. Local: True, IncludeInTestHarness: True Message:Processing referenced file 'C:\dev\TestProject\src\typescript\classSimple.ts' for expanded references Message:Added framework dependency 'C:\Users\myself\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\mfv4e3ra.luv\TestFiles\jasmine\v2\jasmine_favicon.png' to referenced files Message:Added framework dependency 'C:\Users\myself\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\mfv4e3ra.luv\TestFiles\jasmine\v2\boot.js' to referenced files Message:Added framework dependency 'C:\Users\myself\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\mfv4e3ra.luv\TestFiles\jasmine\v2\jasmine-html.js' to referenced files Message:Added framework dependency 'C:\Users\myself\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\mfv4e3ra.luv\TestFiles\jasmine\v2\jasmine.js' to referenced files Message:Added framework dependency 'C:\Users\myself\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\mfv4e3ra.luv\TestFiles\jasmine\v2\jasmine.css' to referenced files Message:Added framework dependency 'C:\Users\myself\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\mfv4e3ra.luv\TestFiles\chutzpah_boot.js' to referenced files Message:Finished building test context for C:\dev\TestProject\tests\jasmine\typescript\simpleSpec.ts Error: 0 : Time:22:47:48.6888513; Thread:23; Message:Can't find location for generated path on C:\dev\TestProject\src\typescript\classSimple.ts Warning: 0 : Time:22:47:48.6978503; Thread:23; Message:Chutzpah determined generated .js files are missing but the compile mode is External so Chutzpah can't compile them. Test results may be wrong. Information: 0 : Time:22:47:48.7038522; Thread:23; Message:Found generated path for C:\dev\TestProject\tests\jasmine\typescript\simpleSpec.ts at c:\dev\TestProject\tests\jasmine\typescript\simpleSpec.js Error: 0 : Time:22:47:48.7088508; Thread:23; Message:Couldn't find generated path for C:\dev\TestProject\src\typescript\classSimple.ts at

そして、それはそれだ:私はChutzpahを使用してスペックを実行すると、まだ私は、次を取得します。事は、私が見ている。 jsファイル正確上記のトレース内に述べた場所に、しかし大胆にこれは、それはユニットテストのために取得するのと同じくらい簡単です

...のために生成されたパスが見つかりませんでしたと主張しています。私はテストが.jsファイルだけを実行すると、テストが合格するため、ファイルが.tsのファイルとは独立して動作することがわかります。

私は間違って何をしていますか?

答えて

2

非常に詳細なreproを投稿していただきありがとうございます。あなたは私が数回見た問題にぶつかっています。あなたのchutzpah.jsonはテストフォルダにネストされているので、ソースから出力フォルダへのマッピング方法を決定するためにchutzpahが使用するフォルダパスマッピングを指定する必要があります。これはただのおchutzpah.jsonを変更するためには:

{ 
    "RootReferencePathMode": "SettingsFileDirectory", 
    "Framework": "jasmine", 
    "Compile": { 
     "Mode": "External", 
     "Extensions": [ ".ts" ], 
     "ExtensionsWithNoOutput": [ ".d.ts" ], 
     "Paths": [ 
      { "SourcePath": "../../../", "OutputPath": "../../../"} 
     ] 
    }, 
    "References": [   
     { "Path": "../../../src/typescript/classSimple.ts" }   
    ], 
    "Tests": [ 
     { "Path": "simpleSpec.ts" } 
    ], 
    "EnableTracing": true, 
    "TraceFilePath": "trace.txt" 
} 

他の問題を回避するには、ちょうどあなたのプロジェクトのルートにchutzpah.jsonを置くことであろう。

これを避けるには、私はチューツパをより良くするために調べる必要があります。私は、このような状況でchutzpahに、この共通の落とし穴を避けるためにファイルが同じ場所にあると仮定してみることにします。

+1

私は将来の人々がこの問題にぶつからないように変更しました。https://github.com/mmanela/chutzpah/commit/9328f3d5f546cecc0ebf8f010b455519324c3de8 –

+0

これは完全に機能しました。 GitHubに調査し、そのアップデートを送っていただきありがとうございます。私は明らかに、その場を取っていませんでした。 – atconway

0

Googleが同様の問題のために、ここで私を導い:

を私の大胆プロジェクトのいくつかの新しいテストは、活字体で書かれており、単一outfileにコンパイルされています

のTSconfig。JSON

"compilerOptions": { 
    "noImplicitAny": true, 
    "target": "es5", 
    "module": "none", 
    "outFile": "./Tests/mytests-ts.js", 
    "sourceMap": true 
    } 

私はPathsオプションを使用するまで大胆に*.tsファイル

Chutzpah Error: System.IO.FileNotFoundException: Couldn't find generated path for D:\Code\ChutzpahProject\Scripts\DateServiceMock.ts 

を見つけることができなかった:これは、ような感じ

chutzpah.json

"Compile": { 
    "Extensions": [ ".ts" ], 
    "ExtensionsWithNoOutput": [ ".d.ts" ], 
    "Executable": "build-ts.cmd", 
    "Paths": [ 
     { "OutputPath": "Tests/mytests-tests-ts.js" } 
    ] 
    }, 

を@ matthew-manelaの答えにコメントしていたかもしれません...と思います。

関連する問題