Mocha timeout using selenium-driver - selenium-webdriver

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"

Related

Jest integration Tests break on Pipeline

Hello im trying to find to build a application on my pipeline using integrations tests with Jest version 27.5.1 as well as jest-cli 27.5.1 all the tests work on my localhost however when my code runs through the Pipeline it shows the following Error
FetchError: request to http://localhost/callback?usid= failed, reason: connect ECONNREFUSED 127.0.0.1:80
and if i add a skip to this test the next test breaks as well
I've tried reading the documentation of jest to see if the root of the problem could be syntax i changed the Url where im doing the request for the API and also cleared added on the function afterEach() server.resetHandlers() as well as LocalStorage.clear() to clear up anything that might be considered Old data

jest.mock - Cannot find module in React test file

I want to mock broadcast-channel in my test case and was following the jest documentation on how to mock a module. However when I run the test, I get an error 'Cannot find module 'BroadcastChannel' from 'broadcast.test.js''
I tried looking at the githubs of both jest and broadcast-channel for similar issues but nothing came up.
Inside broadcast.test.js
import BroadcastChannel from 'broadcast-channel';
jest.mock('BroadcastChannel');
It should run the test case using the mock broadcast-channel. However, I only get the error:
'Cannot find module 'BroadcastChannel' from 'broadcast.test.js''
You can set up a setupTests file, where you can create a manual mock for the BroadcastChannel and set it for the window.
if (!window.BroadcastChannel) window.BroadcastChannel = BroadcastChannelMock;
This applies when you use react-scripts test for running tests.

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

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...

Karma: Running test with phantomjs ends-up with TypeError, while succeeds with Chrome

I have got some angular services and a simple test, which tests that 1 method returns an instance of some type.
When I run it in WebStorm with PhantomJS and Chrome
"browsers": ["PhantomJS", "ChromeCanary"]
All tests are passed in chrome but in PhantomJS some tests will pass, but the test mentioned above produces the type error. (Not the test, but the code which is being tested by the test)
TypeError: 'undefined' is not a function (evaluating 'this._decorateParent.bind(this)')
<... other info>
Sure, I can mock out some dependencies and it will help. But I want to know what is the reason for such behaviour.
angular.js v1.3.14
karma v0.12.32
PhantomJS v1.9.8
Update to PhantomJS 2 which is the easiest way to solve this. PhantomJS 1.x is based on a 4 year old fork of QtWebKit which didn't support Function.prototype.bind at the time. Usually a shim is required to make that function known to PhantomJS, but this might be hard to impossible to do for karma.
If you want to try it with a shim, this one has always worked for me.

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

Resources