17

I am using Visual Studio code, Protractor, Typescript and Jasmine framework. I have spec test cases within "it" block.

To see all the test cases or it blocks I have installed "Jasmine Test Explorer " and "Jasmine Explorer UI" but somehow test cases are not listed.

Could you please help me to resolve this.

enter image description here

coder
  • 8,346
  • 16
  • 39
  • 53
simond
  • 684
  • 1
  • 10
  • 36

2 Answers2

9

Here is a possible solution:

Create a setting pointing to your config file (e.g. in .vscode/settings.json):

{
  "jasmineExplorer.config": "jasmine.json",
  ...
}

In the jasmine.json file, you tell the explorer where the specifications are. Here is an example:

{
    "spec_dir": "site/dist/tests",
    "spec_files": ["**/*[sS]pec.js"],
    "helpers": ["helpers/**/*.js"],
    "random": false,
    "seed": null,
    "stopSpecOnExpectationFailure": false
}
Willem
  • 917
  • 7
  • 19
  • Where this jasmine.config locates? – Chamila Maddumage Mar 25 '19 at 09:27
  • 1
    @ChamilaMaddumage I improved the answer. I incorrectly said `jasmine.config` where I meant `jasmine.json`. Thanks for asking. – Willem Mar 31 '19 at 09:39
  • 1
    To add to this: The default location is normally `spec/support/jasmine.json` so you can just create the file there. I got it by clicking on the settings icon for Jasmine Test Explorer. Also, it's best to set your tests to random (a change from the listed file). – Cobus Kruger Nov 06 '19 at 11:52
  • I had moved the jasmine.json to a different location...addition to `.vscode/settings.json` did the trick! – viperguynaz Dec 16 '19 at 22:51
  • 3
    This answer is for JS files, the question asks about TS tests. Even by updating the file paths, it doesn't work for me. I can see JavaScript tests, but as soon as I add a TypeScript one, *all* tests disappear – djjeck May 10 '20 at 23:44
4

The Test Explorer plugin will not show any test if an error is encountered. To check if there were any errors during the compilation of your tests, go to the Jasmine Explorer Log in the Output tabs of VSCode (View -> Output) enter image description here

You can see that in my case I was having an issue with module resolution that I fixed by tweaking tsconfig.json.

djjeck
  • 1,781
  • 17
  • 25
  • 2
    I cant even see this log item. – Code Name Jack Aug 12 '20 at 20:46
  • 1
    @CodeNameJack find (near the bottom) "jasmineExplorer.logpanel: Write diagnotic logs to an output panel called "Jasmine Explorer Log"" in https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-jasmine-test-adapter – Doug Domeny Jan 05 '21 at 23:12