how to run karma/jasmine tests in visual studio? - jasmine

How can I run karma/jasmine tests? I set up a basic test within a .NET MVC app previously and I'm pretty sure I ran it and it passed but I'm forgetting how to load the runner for the test now.
UPDATE
Looks like package.json needs a "scripts" property with a "test" property.
My "test" property is configured to call "karma start ./karma.conf.js"
My package.json file has the following additional property:
"directories": {
"test": "tests"
},
My karma.conf.js has the following config setting:
files: [
'tests/*Spec.js'
],
However, when I exec cmd "npm test", the tests in my tests/BasicSpec.js file don't get loaded into the browser. Any idea what the issue might be?

Do you have the two Chutzpah extensions installed?
https://marketplace.visualstudio.com/items?itemName=vs-publisher-2795.ChutzpahTestRunnerContextMenuExtension
https://marketplace.visualstudio.com/items?itemName=vs-publisher-2795.ChutzpahTestAdapterfortheTestExplorer
Not sure why you need both, but you seem to.
Once they are installed, you can open the VS Unit Test Explorer, which should show your tests. Click the button to run the tests right inside Visual Studio.
Annoyingly, Jasmine pops up a web page with the results, which is pointless, as the test explorer shows them, and gives loads more functionality, but you can just close the web page and ignore it.
If that doesn't answer your question, please clarify what the problem is, and I'll change my answer.

Related

How can I see the results of my Unit Tests in VS2017?

I'm running unit tests on my GetModelAsync() and CreateModelAsync() methods in VS17. I then run Assert.Equal checks on the model fields to ensure they match the expected values.
I want to be able to see the final state of my models, which will help me determine why a test is failing or allow me to manually check my models. I'm thinking something similar to tracking variables in the debugger would make sense, although I don't want to actually run the debugger.
Is there a way to do this?
You can write to the console in your tests and it will show up in Test Explorer. You may want to serialize complex objects to JSON first before doing this. For example:
Console.WriteLine(JsonConvert.SerializeObject(myObject));
Note, for Visual Studio's built in test runner, you have to go through a few steps to see the console output. In the Test Explorer window, click the name of your test, then in the results panel click the Output link, which will open a separate window to show the console output. It's all very unintuitive.

Unable to run all values from csv file while doing a performance test

Im using VS Web Performance Test Tool.
My Application has a login and few functionalities but doesnt have a logout . I one closes the browser and opens , it asks for login .
Now, i have 5 rows in excel , but only the first is run and it stops.
Please let me know if anyone knows how to make all rows run.
Thanks,
SK
By default, running a Web Performance Test (WPT) only does one execution of the test. A WPT can be called from a Visual Studio Load Test to run it many times by many virtual (i.e. simulated) users (VUs).
A data driven WPT can easily be run more than once by either of two methods.
After the test has been run once, click the "Edit run settings" on the Web Test results viewer. The modified run settings only apply to runs started by clicking the "Click here to run again" and are lost when the Web Test results viewer is closed. See here for more details.
The default can be changed in a .testsettings file. If no such file is already in the solution, then use the context (right click) menu of the solution in Solution Explorer and select Add => New item then follow the prompts to add a Test settings file. The Web test section of the file controls how WPTs are executed. See here for more details.

How do I debug within my WebStorm workspace?

I start my application on localhost:9000 using a grunt serve command. The application is using yeoman. All my node modules and bower components are in place. I am trying to use the inbuilt grunt task runner - right click and debug serve command. However, it starts the debugger in some other port.
I also tried creating run/debug configurations but that does not seem to have a Grunt debug option.
I am using WebStorm 11.0.3. Any pointers to do this?
To debug client-side code of your app create a new JavaScript run/debug configuration. In the URL field specify localhost:9000. Click save, put the breakpoints in your client-side code and hit debug.

No Coverage Data for Tests in Current Context

I'm using Visual Studio 2010 SP1. When I run "All Tests in Solution", I get code coverage results to show up just fine. However, when I run a subset of tests using "Tests in Current Context", I only see "Cannot find any coverage data (.coverage or .coveragexml) files. Check test run details for possible errors."
A Google search shows that others do get code coverage results when running a subset of tests. Is there a configuration I'm missing somewhere?
I think I figured out the reason for this, but it still doesn't make complete sense. If I run the tests in the current context by going to "Test -> Debug -> Tests in Current Context", it doesn't work (code coverage is not generated). However, if I do "Test -> Run -> Tests in Current Context", then it works. So far so good, it kind of makes sense that it would only work when not in Debug mode.
But the strange part is if I use the keyboard shortcut for "Test -> Run -> Tests in Current Context" (Ctrl-R, T), it does not work. So I have to run it from the menu instead of using the keyboard shortcut, otherwise it says no code coverage was generated.

User cannot see TFS2010 test results in VS2010

I have a few lists of tests that I setup for a project that builds to a website. I have a bunch of unit tests and integration tests that runs before deploying the site. I have one user that clicks on the failed build in Build explorer but the Test results(that I can see-all test) that appears below that is empty.
If I click on it I can see a complete list of tests that passed as well as the test that failed. In the "Test Results" window at the bottom there is a drop down list to choose the(it looks like environment??) and when they choose "System#SERVERNAME SERVERTIME" it does not show the list that I can see if I am logged in. It seems to be a permission issue but where?
Thank you
Jack

Resources