I have a problem with tests written in typescript which reference other typescript classes (those under test) when the classes under test are in a different project.
for example I have a solution which contains Project A and Project A.Tests.
The solution has this structure:
A
-Scripts
--Class.ts
A.Tests
-Scripts
--ClassTests.ts
in ClassTests.ts I have this:
///<reference="../../A/Scripts/Class.ts"/>
This builds fine in vs as the relative paths are all fine.
However in NCrunch the build often fails as sometimes the workspace only contains the project A.Tests and not the source for A.
As Typescript files are compiled with an MSBuild step in the csproj this then causes the whole build to fail and NCRunch to not be able to run any of the tests (A.Tests also contains many SpecFlow tests).
this problem has only surfaced since I converted my JavaScript tests into TypeScript tests. I tried included a link to the whole A scripts folder but this only add them in VS and doesn't copy them on the disk.
Workarounds that I can think of are:
Move the typescript tests into A
Have a build step which copies the source from A to A.Tests (not really sure that this will work though)
but I wonder if there is a 'better' solution from an NCrunch point of view, or if you have any suggestions?
Can I some how force NCrunch to always build 2 projects in the same workspace?
At the moment since NCrunch doesn't support TypeScript (nor anything that sits on top of it), my first thought would be that we do have an option to disable the build step that compiles the TypeScript files. The drawback of this is that NCrunch won't report errors in TypeScript though .. so I guess it would need to be weighed up. If you know the name of the build target or a property that controls it, you could use an override to suppress it for NCrunch builds. An advantage of this is that you would also get faster builds for your non TS code.
If receiving TS compile information via NCrunch is of great value to you, then in theory you can solve this problem by including the referenced files using the 'Additional files to include' setting on the project that references them. For example, in the above case, adding the file '..\..\A\Scripts\Class.ts' to NCrunch's the 'Additional files to include' setting in project A.Tests would allow the project to build normally. There are no side-affects that can arise from this as NCrunch will simply treat the file as it belongs in both projects, and it will be copied to workspace for each of the projects. You could also do this with a wildcard if you are sick of chasing down every individual reference, for example '..\..\A\Scripts\**.ts'