I am trying to set up some AngularJS e2e tests with Karma Scenario Test Runner. I did some modifications to the source files, but Karma doesn't seem to use these latest versions when testing.
In the source files, I added ids to some elements. Karma still couldn't find them, so I added a pause in the e2e test, so that I can mark and "Inspect elements" (using Chrome) on the current page in the test runner. The source code seems correct, except the latest changes are missing, i e, the ids aren't there. So what's happening here? Do I need to explicitly tell Karma the files have been updated somehow?
You can fix this issue by forcing angularjs to clear the application cache:
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$viewContentLoaded', function() {
$templateCache.removeAll();
});
});
In Chrome developer tools settings, check "Disable cache (while DevTools is open)".
Obviously, this is a much more general issue than Angular's e2e test runner, but I decided to leave it here for now, in case somebody else has the same question.
Related
I have an app where I am signing in and doing stuff. I want to reuse my signIn.e2e.js file. Basically I want to test dashboard, so I want to log in before that. Hence I want to use my signIn.e2e.js file in homeScreen.e2e.js file.
Any idea how I can do that?
I tried to do some research but haven't found anything. I am using jest test runner, it does have jest-runner-groups, but that's for jest, not for Detox.
Is it possible and if so, how to have TFS display jasmine test results? I am successfully creating jasmine test reports using the plato npm package on the server during a build although I'm yet to link the report to the TFS build success page in TFS. Can someone please advise how this is possible?
Many thanks!!
Update
Initial comments refer to looking at the following link although I think this is a general link in TFS as opposed to a link relative to the "current" build.
https://www.visualstudio.com/en-us/docs/integrate/extensions/get-started/node
I have a build definition that cleans, compiles and runs jasmine tests and using plato (npm install plato) creates a html report on the server. I want developers looking at the build to be able to open the report for the build that they're looking at. Please confirm is the suggested extension link is still applicable because I've tried it just now without success.
Please advise.
Update
I've successfully included NUnit tests to be executed in our build, shown in the screen shot. I want to have a similar feature for Jasmine. The second screen shot shows the report page the Plato package produces for Jasmine tests. I would like this available within the TFS results page.
Screenshot #1 - NUnit test results (as seen in TFS)
Screenshot #2 - Plato produced jasmine results report
This reported is generated on the server in a build definition step.
You can add a custom section in build result through extension, with this way, you can add the link in that custom section.
There is the sample about build result extension:
vsts-extension-samples
More information about how to build extension, you can refer to this article (apply to on premise TFS)
Create your first extension for Visual Studio Team Services
You can use tampermonkey to inject a link into TFS. The following will work. (It's horrible but I haven't achieved the same result with any "proper" approach).
Example script
(function() {
'use strict';
setTimeout(function() {
$(".pivot-view.pivot-tabs").append("<li><a href='plato-report.html' target='_blank'>Jasmine tests</a></li>");
}, 3000);
})();
https://tampermonkey.net (for chrome)
https://addons.mozilla.org/en-gb/firefox/addon/greasemonkey/ (for firefox)
Is it possible to run single Jasmine test it or suite describe in IntelliJ from popup menu as it possible with JUnit or TestNG fremeworks?
Now I can only execute tests by running karma.conf.js that will grab all specs and run them which is not exactly what I want.
Updates
This is known issue please upvote it.
You don't need Intellij's help if you are trying to run a single unit test or a single test suite while using Jasmine. You can do that with their feature of fit() and fdescribe(). Here, prepending it(...) and describe(...) with f says those are focused tests/test suites.
Quoting the documentation (Jasmine 2.1 and above),
Focusing specs will make it so that they are the only specs that run.
Any spec declared with fit is focused.
You can focus on a describe with fdescribe
You could follow this issue in YouTrack - https://youtrack.jetbrains.com/issue/WEB-13173.
We have supported --grep[1] option for jasmine in karma already.
But there are some open discussions about problems in large projects[2]
[1] - https://github.com/karma-runner/karma-jasmine/pull/56
[2] - https://github.com/karma-runner/karma/issues/1235
Thanks!
With WebStorm 2017.1 it's possible to use RunConfiguration producer to run a single Karma test: https://github.com/develar/ij-rc-producer
The Durandal Test Framework runs Jasmine tests within PhantomJS.
Where I'm implementing this for the first time I'm getting a lot of errors, and reading through these on the command prompt is proving to be very tedious.
If I load up the spec.html file in my web browser, it tells me that no specs were found:
Yet PhantomJS is able to find the specs with no problem:
Is there a way I can configure these Jasmine tests to run through my web browser and not through (or as well as) PhantomJS?
I've set up a new index.html file and have replaced the var runTests = ... section with a simple require() call:
require(['../test/specs/system.spec.js']);
Durandal's system.spec.js file is loaded in the browser, but Jasmine is still stating that no specs were found.
Jasmine's tests weren't being run because I wasn't telling it to re-execute. The solution to this was to simply re-execute by calling this within the require callback:
require(['../test/specs/system.spec.js'], function() {
jasmine.getEnv().execute();
});
Note: A drawback of this is that the 'no specs found' bar is still present and the 'raise exceptions' control on the re-executed specs doesn't appear to function:
I am running Jasmine tests on Karma (latest, 0.12.14) from IntelliJ IDEA (latest, 13.1.2) on OS X.
IntelliJ just uses Karma plugin that points to my karma installation: /usr/local/lib/node_modules/karma
The problem is that Karma watcher doesn't pick new changes from JS files. When I run tests again, everything is fine. It's not a huge issue (they run pretty fast), but it's annyoing to always run tests twice after you do a change.
Anybody experienced similar issue?
Add the following property to your karma.conf.js file:
usePolling: true
I put it after the autoWatch flag.
Reference: AutoWatch doesn't work #895
Finally got this to work. This is a known issue when using Karma in IntelliJ with build tools like Webpack / Gulp / etc... and that the post-processed files are outside of the files that Karma is directly serving.
The workaround is to manually modify the IntelliJ config in this file: ...\plugins\js-karma\js_reporter\karma-intellij\lib\intellijRunner.js
At or near line #75 in the runWithConfig() method, change the refresh property --> true.
See this comment for details
Had this issue in both IntelliJ and Webstorm and fixed both the same way.
In the case of using IntelliJ IDEA, maybe try
Preferences > General > Uncheck "safe write"
I am not sure if question is still actual, but i found a solution (or just a workaround).
I changed this file C:\Users\MyUser\.IntelliJIdea14\config\plugins\js-karma\js_reporter\karma-intellij\lib\intellij.conf.js a little bit here:
config.singleRun = false;
var originalAutoWatch = config.autoWatch;
//config.autoWatch = false; <-- this line
config.autoWatchBatchDelay = 0;
For sure the plugin maintainers had some reason to add this line, but for me this worked fine enough (there were isolated crashes I can't reproduce).
I am not sure about older versions of intelij but I am using 2016.3 (the latest version at the time of writing this) and it all works OK assuming karma config has autoWatch: true.
Having exactly the same problem all I have to do was to switch on Toggle auto-test in intelij and all started working fine without any other change.
Please check autoWatch property in karma config file set to TRUE.
Also if you are using Sublime Text 3 then set "atomic_save": false in your user settings as it also causes issues with watches. see here
Macros worked for me. After trying usePolling: true, modifying the intellijRunner.js, and unchecking Safe Write I still had to save or run tests twice to catch the changes.
Made a compound macro to both Save and Run File and Save and Re-Run Test. Then I overwrote each commands' shortcut via Keymap.
How to bind multiple actions to a shortcut
screenshot of macro: Save and Run test at cursor
screenshot of macro: Save and Re-run last test
screenshot of Keymap for macros