Why are some Protractor tests skipped? - testing

When I launch protractor conf.js and this file needs to launch multiple spec files (like below), some of them are (randomly?) skipped. It works quite well when I run each spec separately.
specs: [
'tests/test-1-*.js',
'tests/test-2-*.js',
'tests/test-3-*.js'
],
I've found a workaround, but now I would like to know the root cause... Any idea?

Related

JUnit5 Console Launcher not finding tests

I've seen a number of posts on this, but none of the solutions seem to work for me.
The problem is that the JUnit5 console launcher cannot seem to find my tests, regardless of syntax that I try. I've tried scanning for them with --scan-classpath and specifying the class directly with -c, including the package specifier, which generates a NoClassDefFound.
With --scan-classpath the console launcher runs successfully, but doesn't include any unit test executions - doesn't find the test classes for some reason.
The tree looks like this:
junit-5-jars (the console standalone jar is in here)
src
mypackage
MyClass.java
MyClass.class
test
mypackage
MyClassShould.java
MyClassShould.class
From the root of that, the first and most basic command I tried:
java -jar junit5-jars/junit-platform-console-standalone-1.7.0-all.jar --class-path=test --class-path=src --scan-classpath
All variations I've tried give me:
Test run finished after 27 ms
[ 2 containers found ]
[ 0 containers skipped ]
[ 2 containers started ]
[ 0 containers aborted ]
[ 2 containers successful ]
[ 0 containers failed ]
[ 0 tests found ]
[ 0 tests skipped ]
[ 0 tests started ]
[ 0 tests aborted ]
[ 0 tests successful ]
[ 0 tests failed ]
This is on a Mac from bash. In a project with all class files at the root of where I'm running the command, I can run tests with the console launcher successfully. But if class files are in subdirectories like this, no go. Anyone have ideas? (Note - see answer below, subdirectories were not the issue - the "Should" in the test class name was).
I think I've discovered the source of this problem - it was the "Should" in the test class name, which JUnit5 ConsoleLauncher does not include to be scanned by default.
This works:
java -jar junit5-jars/junit-platform-console-standalone-1.7.0-all.jar --class-path=test:src --include-classname=.* --scan-classpath
The include classname option takes a regex, but in my case I just let it scan all the files on the classpath for tests, and it finds them as it should.
Would be helpful if the --scan-classpath description in their docs referenced the include-classname option and/or their default scanning inclusions. Easy to miss that argument in that wall of options.

ERROR:process_metrics.cc(105)] NOT IMPLEMENTED [duplicate]

Recently, we've started to get these kind of warnings on the console when running Protractor tests:
[12252:14584:1207/223118.187:ERROR:process_metrics.cc(105)] NOT IMPLEMENTED
[12252:14584:1207/223118.187:ERROR:process_metrics.cc(105)] NOT IMPLEMENTED
[12252:14584:1207/223318.188:ERROR:process_metrics.cc(105)] NOT IMPLEMENTED
It feels like they happen randomly but doesn't affect the test execution.
The only problem is that they pollute the output console making it more difficult to keep track of tests being executed and test results reported by jasmine/protractor.
Is there a way to turn off this kind of chromedriver warnings?
Using Protractor 5.2.2, ChromeDriver 2.34.
We've found this --silent flag that can be passed to chromedriver executable, but could not find a way to configure protractor to pass this flag when launching chromedriver..
It seems to be an issue with chrome v63
https://github.com/SeleniumHQ/selenium/issues/5189#issuecomment-351605839
You should be able to pass the --silent flag to chromedriver in your conf file. Something like:
capabilities: {
browserName' : 'chrome',
'chromeOptions' : {
args: ['--silent']
}
}
}
"This warning message was generated by a bug in Chrome v63.
Upgrading to v64 (64.0.3282.167 as of this morning) resolves it."

How to run single Jasmine test in IntelliJ IDEA

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

AngularJS : e2e tests with Karma Scenario Test Runner using cached source?

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.

Test browser code with Intern through Grunt and Phantomjs

I have been playing with Intern and made my tests work in the browser. To better integrate with my current workflow I'm trying to run my tests through grunt with phantomjs. However all my attempts have failed. I've been looking at this question as a reference Intern WebDriver and PhantomJS but can't figure out all of the steps to make it work.
First of all: Is it even possible to run the tests through grunt and phantomjs?
A little bit of info:
I don't want/can't connect to Sauce Labs or a Selenium testing environment.
I want to test browser code while having jQuery as a shimmed dependency
I have Grunt 0.4.1 and phantomjs 1.9.1 installed
I'm not testing any ajax request (as the linked question is having problem with)
I'm not familiar with neither Selenium nor Sauce Lab
If it is possible to test through grunt and phanomjs, how would I go about doing it?
I guess that I have to start the GhostDriver
phantomjs --webdriver=8910
But then what are the important pieces of info in the Intern config to make this work?
define({
proxyPort: 9000,
proxyUrl: 'http://localhost:9000/',
environments: [
{
browserName: 'phantom',
version: '1.9.0',
platform: 'Linux'
}
],
webdriver: {
host: 'localhost',
port: 8910
},
maxConcurrency: 3,
useSauceConnect: false,
// ...
});
How does the environments browserName map to phantomjs? I've tried the browserNames 'phantom' as well as 'phanomjs' with different versions and platforms (running Mac 10.7)
My Gruntfile section for intern looks like:
intern: {
phantom: {
options: {
config: 'tests/intern',
reporters: ['webdriver']
}
}
}
Running this setup without any test-suite that includes browser code outputs
'ReferenceError: document is not defined' in 'node_modules/intern/lib/reporters/webdriver.js:41:19'
Adding browser tests gives 'ReferenceError: window is not defined' in 'src/vendor/jquery/jquery-1.9.1.js:9597:5'
Running it through node gives the same 'window is not defined' error.
node node_modules/intern/client.js config=tests/intern
What am I doing wrong/missing here?
There are two problems with your Gruntfile configuration:
The default run type for the Grunt task is 'client', which means it runs the Node.js client by default, not the test runner. You need to set runType: 'runner' in your Gruntfile options to run tests against your specified environments.
The webdriver reporter is for use in a browser client only and is specified automatically by the test runner when it is needed. You should typically never use it directly. The reporter you specify in the Gruntfile should be the one you want the test runner to use; the console default is usually appropriate.
These two things in combination mean that you’ve configured Intern to try to use a reporter that only works in a browser in conjunction with the test runner inside the Node.js client, hence the error. Once corrected, the remaining configuration should work properly to run on PhantomJS, assuming it is already running on localhost at port 8910.