1

I'm writing an integration test to cover some Typescript classes that I've got, and those Typescript classes have dependencies on third-party JS libraries.

The Integration test is also written in Typescript. When I run the test using Resharper's built-in support, there is a JS error in the browser saying that the third-party dependencies can not be found. Of course, the test runner has not added references to them when constructing the test page for the browser. I try and add the references using the <reference> statement in the test file, but the IDE (VS 2013) complains that you can only use to refer to other Typescript files - not Javascript files.

How can I solve this problem?

I have used the Chutzpah test runner in the past, with its various plug-ins for VS, and that lets me define such references using the <chutzpah_reference> statement. But I was wondering if it was possible to just use Resharper from now on...

Simon Green
  • 1,131
  • 1
  • 10
  • 28

1 Answers1

0

JetBrains has this on their radar for Resharper: https://youtrack.jetbrains.com/issue/RSRP-389196 where the following workaround is proposed.

Include references to *.d.ts files in your TypeScript test files. Then put your third-party JS libraries in matching .d.js files in the same directory.

For example, if you would want to reference the trial.js file, like you said, you can't just do this because typescript complains:

/// <reference path="scripts/trial.js" />

So instead, create a file at scripts/trial.d.ts and add

/// <reference path="scripts/trial.d.ts" />

Then rename (or copy) scripts/trial.js to scripts/trial.d.js. The Resharper test runner will see the trial.d.ts reference and include the trial.d.js script in the test fixture HTML it generates.

Mike Schenk
  • 1,512
  • 9
  • 21