typescript-collections jasmine visual studio 2015

我的梦境 提交于 2019-12-12 03:45:16

问题


I am currently in the process of learning how to test my typescript code using VS2015, with resharper, and Jasmine (v 2.4.1) and it is not going very smooth. I trying to use typescript-collections from https://github.com/basarat/typescript-collections.

The following seems to work fine:

describe("collection Tests",
  () => {

  it("collection should work",
     () => {

        expect("123").toBe("123");
  });
});

When i execute the test from VS2015 (using resharper) then it starts my webbrowser and reports that the test passed.

When i do the following:

import * as Collections from 'typescript-collections';

describe("collection Tests",
  () => {

  it("collection should work",
     () => {

        var collection = new Collections.Dictionary<string, string>();

        expect("123").toBe("123");
  });
});

i see the following in my browser: No specs found

Some pointers to get this to work would be really helpful.


回答1:


I encountered this too. Resharper support was able to provide me a starting point, but not a full solution.

Typescript transpiles your import statement into some type of module format (depending on your Typescript configuration). The Resharper test runner executes the tests with no knowledge of any module loader.

Other test runners will sometimes include a way to include and configure a module loader, but this option in Resharper appears to be very limited. Their documentation provides a very brief description of how to configure a test harness file, but it relies on Chutzpah compliant template placeholders. This is a high friction path. Even Chutzpah documentation provides a bold paragraph warning of the perils of doing this. The Resharper tools for Javascipt testing aren’t nearly as mature as they are for other VS languages. As much as I prefer to stay in the VS IDE and use familiar tools, I’ve decided to stick with more native JS tools for testing.



来源:https://stackoverflow.com/questions/38747521/typescript-collections-jasmine-visual-studio-2015

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!