Protractor Config : Error on calling Suties for testing non-Angularjs web - angularjs

When I test using protractor testing on Non-Angullarjs website, I try to call one specific case, so I use --suite example_A, it will run example A test case,however, after example_A is completed, it will run example_B too.
My config for suite is like this :
suites: {
example_A : "../test_case/homepage/example_A.js",
example_B : "../test_case/homepage/example_B.js"
},
is it a bug or protractor just doesn't support non-angular website well?

While I can't reproduce this, I'm guessing that your default specs property in your config is set to run all tests? I.e. it's defaulting back to the config for which testes to run. If so, try removing that from your config and run again?
You should also be using the "=" when running your tests. Eg. --suite=example_A, but I tried this, but still couldn't reproduce the problem. Still...

Related

Karma Istanbul fix to work with new version of Chrome

In my AngularJs application I'm using Jasmine and Karma for my unit tests.
Recently, after a chrome update (now on 72.0.3626.81) my unit tests starting failing locally (with no change to code). I believe the error is a result of my coverage tool Instanbul.
Sometimes the error appears like this:
An error was thrown in afterAll Uncaught ReferenceError: __cov_iuQO6FdumXRPLjSMopb0JQ is not defined thrown
Other times it will appear within a specific unit test (not sure why).
I searched my application and the only file this __cov_ variable could come from is the return of a function within the Instanbul package, generateTrackerVar() within instrumenter.js.
As no code changes were made I assume that the issue is with the new version of Chrome, perhaps the security settings.
My question what permissions would karama-coverage/istanbul require? OR if anyone suspects the issue isn't security based, then what could be causing this error?
Thanks
EDIT:
I have tried to disable web security in my gulpfile like so:
browsers: [ 'Chrome_without_security' ],
customLaunchers: {
Chrome_without_security: {
base: 'Chrome',
flags: ['--disable-web-security']
}
},
But this didn't solve the issue. Is there a way to set the chrome version in this config?
I managed to solve this by figuring out the hashcode after __cov_ was related to a test file that was throwing an error. I don't know why the error didn't just appear as it normally would, that will be another problem to solve.
For now I managed to figure out the file by logging in instrumenter.js within the instanbul package. Then by removing my coverage tool I figured out the source of the issue. Simply removing the coverage tool would give me a different error but not tell me which file so I needed to do both.

Mocha timeout using selenium-driver

I am trying to launch my mocha tests using selenium-driver but I got this error : https://gist.github.com/Clemzd/f7bbaa77c492ee288765#file-gistfile1-txt.
My selenium-server is well started because I'm able to run a chrome session.
Here is the code I used to launch my mocha tests : https://github.com/Clemzd/paige-tests.
I tried to increase the timeout for mocha but it does not change anything.
selenium-webdriver/testing seems to have a hard time with mocha versions above 1.20. You can get this error to go away by changing the mocha dependency in your package.json to look like this:
mocha: "~1.20.1"

Sinon.stub works in karma, mocha with chrome running but not headless

I am working on an angularjs project where if a user scrolls on an element, the element calls scrollTop() to determine if another method should be called.
I wrote this sinon.stub
scrollTopStub = sinon.stub($.fn, "scrollTop").returns(50);
This is the validation
expect($.fn.scrollTop.calledOnce).to.be.true;
The tests pass when I run them using karma, mocha and chrome.
However, when I run the tests headless the sinon stub is never called.
Any thoughts?
I know this is an old question. But if someone bumps into this: this is probably a completely different issue. I run into a similiar one once almost been driven crazy by cryptic and misleading errors when running with phantomjs (I assume this is the headless browser) - in the end I found out that Phantomjs doesn't support bind (and some other es5 methods So code using them would fail. just adding es5 shim to the test index.html (or karma.conf or.. ) file solved the problem. Since I used sinon.js with phantomjs in another project I know this can work correctly

AngularJS + Testacular / Jasmine unit tests: Executed 0 of 0 SUCCESS

I am trying to write unit tests for an AngularJS project. The project is based on angular-seed and uses Testacular to run tests. Every attempt to run test.sh script always ends up with "Executed 0 of 0 SUCCESS".
I tried this super-simple "test":
describe('Testing Jasmine', function() {
console.log('describe');
var test = 'test';
it('should be test', function() {
console.log('it');
expect(test).toEqual('test');
});
});
The result is that only 'describe' is logged, the 'it' part is skipped. When I try the same thing on clean angular-seed clone everything works - so I assume that the testing system itself with Testacular and Jasmine is working correctly.
Our project is based on Rails, but the clean angular-seed that I was testing for comparison is running on Apache so I thought that this might be the difference - messed up paths or something in that Rails project.
But there are no error messages, e2e tests work... and also I assume that if some files were missing or paths were incorrect it would not be able to log that 'describe' in tests - if I understand correctly this means that Jasmine is processing the right file (there are no other dependencies in this pseudo-test). How is it possible that the 'describe' part works just fine and only 'it' part seems to be skipped?
Any hint or help would be appreciated.
If you are doing unit tests, do not include the angular-scenario.js file in your testacular config file. That will break the unit tests.
e2e testing in testacular has a long way to go. I struggled with this for a while. It turns out that the left side of an expect must be one of the methods defined in the angular documentation: http://docs.angularjs.org/guide/dev_guide.e2e-testing.
the following is an example
describe('Testing Jasmine', function() {
it('should be test', function() {
expect(element('foo').count()).toEqual(1);
});
});
Remember, if you dont enter in one of the prescribed method calls into the expect, testacular will not run the 'it'
Also make sure that you have one of these attributes used on page you are testing:
'ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'
Because if function angularInit() won't find element with one of these arguments runner won't start.
This is espcially important if you would like to use angular test runner on webage that does not have ng-app - with current version it just won't work.
Please check the order of the Javascript files.
A similar issue was reported in Testacular and reordering the js files fixed the problem.

How to run angularJS tests in intellij idea 11.1.3?

I am new to AngularJS to JS in general. Now I want to use JSTestDriver and behavior driven development framework Jasmin . As I understood AngularJS works with Jasmine and test driver. I am working with Ideal Intellij 11.1.3. I added the plug in for JsTestdriver to It and run some test as described here http://code.google.com/p/js-test-driver/wiki/IntelliJPlugin. Now here is the problem. When I write some Jasmine tests like this one
describe("A suite", function() {
it("contains spec with an expectation", function() {
expect(true).toBe(true);
});
});
, for the first time indea intellij asked me to download the jasmine adapter and I did, but when I run the test I got this message : unable to attach test reporter to test framework intellij. I searched google for solutions, some guy posted how to run the angular tutorials: here : https://groups.google.com/forum/?fromgroups=#!topic/angular/LdjNsZD69Uk.
he uses a configuration files that comes with Angular js. and Node.js should I install them too ? isn't there any way to automatically do this from ideal intellij ?
What files structure should I have ?
Any help, link or suggestion will be great.
I fixed my jsTestDriver.conf file and it's paths, but now I get this problem :
Testing started at 1:31 PM ...
Cannot read [
/tmp/.m2/repository/org/testng/testng/6.7/testng-6.7.jar!/testng-reports.js
/home/clouway/.m2/repository/org/testng/testng/6.7/testng-6.7.jar!/testng-reports.js
] derived from .m2/repository/org/testng/testng/6.7/testng-6.7.jar!/testng-reports.js
Cannot read [
/tmp/.m2/repository/org/testng/testng/6.7/testng-6.7.jar!/jquery-1.7.1.min.js
/home/clouway/.m2/repository/org/testng/testng/6.7/testng-6.7.jar!/jquery-1.7.1.min.js
] derived from .m2/repository/org/testng/testng/6.7/testng-6.7.jar!/jquery-1.7.1.min.js
at com.google.jstestdriver.PathResolver.resolve(PathResolver.java:98)
at com.google.jstestdriver.config.ParsedConfiguration.resolvePaths(ParsedConfiguration.java:99)
at com.google.jstestdriver.config.Initializer.initialize(Initializer.java:86)
at com.google.jstestdriver.embedded.JsTestDriverImpl.createRunnerInjector(JsTestDriverImpl.java:368)
at com.google.jstestdriver.embedded.JsTestDriverImpl.runConfigurationWithFlags(JsTestDriverImpl.java:342)
at com.google.jstestdriver.embedded.JsTestDriverImpl.runConfiguration(JsTestDriverImpl.java:233)
at com.google.jstestdriver.idea.TestRunner.runTests(TestRunner.java:195)
at com.google.jstestdriver.idea.TestRunner.executeTestCase(TestRunner.java:131)
at com.google.jstestdriver.idea.TestRunner.unsafeExecuteConfig(TestRunner.java:122)
at com.google.jstestdriver.idea.TestRunner.executeConfig(TestRunner.java:97)
at com.google.jstestdriver.idea.TestRunner.executeAll(TestRunner.java:88)
at com.google.jstestdriver.idea.TestRunner.main(TestRunner.java:330)
Empty test suite.
I Use maven as my build tool.
I haven't used JSTestDriver in IntelliJ, so I can't address your question directly. However, AngularJS has moved from JSTestDriver to using Testacular (http://vojtajina.github.com/testacular/), so you might want to do the same. The link includes some setup help getting it running in WebStorm which should be the same.
Looks like he's renamed it "Karma" (http://karma-runner.github.com/)

Resources