Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Typescript tests which reference typescript files in other projects cause build to fail
samholder
#1 Posted : Saturday, November 1, 2014 12:46:30 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 5/11/2012(UTC)
Posts: 94

Thanks: 28 times
Was thanked: 12 time(s) in 12 post(s)
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?
Remco
#2 Posted : Saturday, November 1, 2014 10:02:41 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for sharing this issue.

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'

1 user thanked Remco for this useful post.
samholder on 11/4/2014(UTC)
samholder
#3 Posted : Tuesday, November 4, 2014 1:02:08 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 5/11/2012(UTC)
Posts: 94

Thanks: 28 times
Was thanked: 12 time(s) in 12 post(s)
Thanks Remco. Disabling the Typescript compilation when NCrunch is resident ended up being the solution I went for. Works fine.
1 user thanked samholder for this useful post.
Remco on 11/4/2014(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.037 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download