ReSharper Jasmine AngularJS unit-test using yeoman - unit-testing

I'm trying to get unit-test generated by yeoman to run in Visual Studio using Resharper 8.0.2.
With yeoman if you simply generate a controller you'll get something like this:
'use strict';
describe('Controller: MainCtrl', function () {
// load the controller's module
beforeEach(module('angularYeomanTestApp'));
var MainCtrl,
scope;
// Initialize the controller and a mock scope
beforeEach(function() {
inject(function($controller, $rootScope) {
scope = $rootScope.$new();
MainCtrl = $controller('MainCtrl', {
$scope: scope
});
})
});
it('should attach a list of awesomeThings to the scope', function () {
expect(scope.awesomeThings.length).toBe(3);
});
});
I already have transferred the knowledge of this post because yeoman doesn't generate the anonymous function before the inject statement.
Problem is that I'm always getting errors for each tests like:
Inconclusive: Test wasn't run
Resharper is configured to run tests using the chrome browser and jasmine seems to be properly included into the test page when it opens, but the test page is empty!
Running the tests with karma using e.g. grunt test does work!
Thanks for help!
PS.: I'm using: Visual-Studio-2013, Resharper 8.0.2, angularjs 1.2.6

Karma and Reshaper have nothing to do with each other. You do not have to have karma running or installed to run Resharper tests. For resharper tests you have to have , as I indicated in the comment above, all files you need included as "reference" in each test file.

Related

configure jasmine to not run tests randomly

i just upgraded to jasmine 3.3 and now my tests by default run in random order. Is there a way to configure karma and jasmine to make tests run like they used to before upgrading to this new version?
In Karma config under client: you are supposed to be able to set jasmine:{random:false} but that does not work for me. Does it for you?
See below link from docs and screen cap.
https://github.com/karma-runner/karma-jasmine
A well-written unit test case should provide the same result independent of its execution order.
However, We can change the execution order of Jasmine
Example 1- Add command line flag if you are just using Jasmine
jasmine test/sample.test.js --random=false //global installation
npx jasmine test/sample.test.js --random=false //local installation
Example 2- with karma add this to your config object.
module.exports = function (config) {
config.set({
client:{
jasmine:{
random:false
}
},
// rest of karma configuration goes here
};
//tested with karma 6.3.4 and jasmine v3.8.0

How to add Sinon to angular 2 testing?

I want to add Sinon for testing but I can't get it to run.
I've installed sinon and karma-sinon as DevDependencies.
added sinon to Frameworks in my karma config file.
frameworks: ['jasmine', 'browserify','sinon'],
and in my test file I'm trying to declare a spy
let setTokenSpy = sinon.spy(sbHttpObiject, 'checkForToken');
and I'm getting
TypeScript error: app/sdk/test/http.spec.ts(87,22): Error TS2304:
Cannot find name 'sinon'.
Any help much appreciated! Btw, i think jasmine has also spies but i can't get them to run either, any updates on that?
EDIT----------------------------
---------09.09.2016
meanwhile i've found out that I need to install typings like
typings install dt~sinon --save --global
But now I'm getting this error
ReferenceError: Can't find variable: sinon in
/var/folders/ld/2g86bbq11tddvbnzlzbtg2r80000gn/T/78dc4c45b42a2dd7bfcfb607366d1d15.browserify
(line 350)

State of Jasmine Unit Test support of Resharper 2017: Debug mode and AMD modules supported?

I currently use Chutzpah to run and debug Jasmine Unit tests that include AMD/require.js modules. I would like switch to the test runner of Resharper 2017. However, Resharper does not seem to fully support Jasmine Unit Tests?
A. Example jasmine test:
/// <reference path="../../bower_components/requirejs/require.js" />
/// <reference path="../../bower_components/jasmine-core/lib/jasmine-core/jasmine.js" />
describe('dummy example test', function() {
it("should return bar", function () {
expect(true).toEqual(true);
});
});
The Test can be run with Resharper but the Debugging option is disabled:
B. Example test with module definition:
/// <reference path="../../bower_components/requirejs/require.js" />
/// <reference path="../../bower_components/jasmine-core/lib/jasmine-core/jasmine.js" />
define(['Squire'], function(squire) {
describe('dummy example test', function() {
it("should return bar", function() {
expect(true).toEqual(true);
alert('has been executed');
});
});
});
If I start that with Resharper the test never ends and the it method is not called.
Is it true that Resharper 2016 does not yet support the Debugging of Jasmine unit tests and neither the usage of AMD modules with unit tests? Or do I need to somehow adapt my Resharper settings to get Debugging and AMD/requirejs modules to work?
Here are my current settings:
(Since both Chutzpah and Resharper 10 use outdated versions of Jasmine I am also open for further suggestions that integrate well with VisualStudio.)
Edit: Resharper 2016 seems to support Jasmine Versions > 2.0.
Related (not up to date?) articles:
https://youtrack.jetbrains.com/issue/RSRP-427836
https://devnet.jetbrains.com/message/5528577
http://www.neovolve.com/2015/01/30/resharper-jasmine-and-requirejs/
Jasmine and Requirejs in Resharper 7
How to test spa js modules with resharper testr jasmin?
Front end javascript testing using Require and Resharper
How do you debug Jasmine tests with Resharper?
Jasmine tests in Resharper don't stop executing
Edit
The questions have been originally posted for Resharper 10. They are still valid for Resharper 2016.
As of ReSharper 2016.1:
A. Debugging JavaScript tests is not supported. Here is the feature request.
B. AMD is not supported. Here is the related ticket.

How to configure Ember 2.0 for Integration Testing

I created a sample ember-cli project using ember 1.13.5. I create one component and a dummy integration test. It runs just fine.
import { moduleForComponent, test } from 'ember-qunit';
moduleForComponent('selected-product', 'Integration | Component | selected product', {
integration: true
});
test('amount', function(assert) {
assert.equal(100.00, 100.00);
});
I then update my ember version to 2.0.0-beta.3 in my bower.json file, run the tests, and receive an immediate error:
TypeError: 'undefined' is not an object (evaluating 'Ember.View.extend')
TypeError: 'undefined' is not an object (evaluating 'this.cache.subject')
There is literally nothing else custom in my projet. I just generated it. I realize it's beta software and not quite ready for primetime, but if anyone knows of a simple configuration change, I would appreciate it. I'm using ember-cli version 1.13.1.
You'll need to the latest version of ember-qunit, v.0.4.4 as of today, as ember-2.0.0-beta.3 compatibility was added in this commit. The version of ember-cli you are using does not come with this version of ember-qunit.

How to unit test Dart in Phpstorm

I installed the dart plugin, set the SDK home path to the dart-sdk folder, configured the scope and checked the 'Dart SDK enabled' option in Phpstorm 6.0.3. Next, I created a dart file in a 'test' directory with the following code (obviously I added the dependency unittest in my pubspec.yaml and ran pub get):
library mytests;
import 'package:unittest/unittest.dart';
main(){
test('my test', (){
expect(1+1, equals(2));
});
}
When I run this unit test however (by right clicking inside the file and selecting 'Run Test: my test', an error is outputted in the unit testing window stating the following:
C:/dart/dart-sdk/bin/dart.exe --ignore-unrecognized-flags --package-root=C:/Users/myname/dart/pokerdart/test/packages/ C:\Users\myname\AppData\Local\Temp\jetbrains_unit_config.dart
Testing started at 18:55 ...
'file:///C:/Users/myname/AppData/Local/Temp/jetbrains_unit_config.dart': error: line 1 pos 1: unresolved implicit call to super constructor 'Configuration()'
import 'package:unittest/unittest.dart';
^
When I run the test using powershell it just works... Am I missing something/doing something wrong?
Any help is greatly appreciated!
WEB-9636 is fixed in version 7. Please try upgrading to PHPStorm 7.1.3. Or, even better, try PHPStorm 8 EAP (http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program) - Dart support has been improved there