Informative stacktraces with karma+browserify, how? - karma-runner

I have a problem with assertion traces - they are not enough informative.
For an instance assertion fault:
should navigate inside of layout
PhantomJS 2.1.1 (Linux 0.0.0)
1) serialize#http://localhost:9876/base/node_modules/mocha/mocha.js?0491afff0b566ea45cd04c9164a355dba705689e:10776:34
processAssertionError#node_modules/karma-mocha/lib/adapter.js:59:50
node_modules/karma-mocha/lib/adapter.js:129:49
I've tried karma-sourcemap-loader, but it does not affect the output for me.
My config:
frameworks: ['mocha', 'chai', 'source-map-support', 'browserify'],
files: [
'tests/**/*.js'
],
browserify: {
debug: true
},
preprocessors: {
'tests/**/*.js': ['browserify']
},
reporters: ['progress', 'nyan'],
Any ideas ?

It seems like problem related to source-maps support by different browsers, this configuration works just fine with chromium browser, but does not provide readable stack-trace information when i'm testing with phantomjs browser.

Related

Protractor - log type 'performance' not found error

webdriver-manager 12.1.5
protractor Version 5.4.2
Chrome version 75.0.3770.100
browser.manage().logs().get('performance');
This used to work fine before upgrading my webdriver-manager and protractor version.
(node:27715) UnhandledPromiseRejectionWarning: WebDriverError: invalid argument: log type 'performance' not found
(Session info: chrome=75.0.3770.100)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info:, os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.4', java.version: '1.8.0_191'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (node_modules/selenium-webdriver/lib/error.js:546:15)
If I comment the browser.manage().logs().get('performance'); and other performance related code, then the test runs fine.
webdriver-manager logs show:
Starting ChromeDriver 75.0.3770.90 on port 12268
I came across a potential solution on this github issue thead. Apparently recently chromedriver has started to more strictly adhere to W3C standards and this has affected how webdriver activates logs.
We can get around this issue by setting the w3c: false flag in chromeoptions like so.
capabilities: {
browserName: 'chrome',
loggingPrefs: {
browser: 'ALL',
driver: 'ALL',
performance: 'ALL',
},
'goog:chromeOptions': {
perfLoggingPrefs: {
enableNetwork: true,
},
w3c: false,
},
},
New version might not support performance log type. You can always use getAvailableLogTypes function to check supported log types. I tried following code
var supportedLogTypes = await browser.manage().logs().getAvailableLogTypes();
received ouptput :
It means you can only use either of two supported log types.
I tried out the same thing with chrome 75.* and protractor 5.4.2 version. Following are my findings.
loggingPrefs object is one of the recognized capabilities like chromeOptions. This object allow us to decide preferences on logging part. Refer link for more details about capabilities.
In protractor context we have to pass loggingPrefs object to capabilities to enable it.
Once we pass it then we can use browser.manage().logs().get('performance'); to get all performance logs.
If you want to change perfLoggingPrefs then it is part of chromeOptions object and it has to be updated there. If we want to use default then no need to mention.
chrome use more strictly rule for w3c, when I test chrome driver 96, set w3c to false, I can get network log, but find_element failed and return dict value which is not WebElement

Multiple browsers are opened, but only one browser running spec. other browsers are idle

I am trying to achieve parallel test execution in protractor. With the below mentioned code, I can open multiple browser. But only one browser running the spec, rest are just opened.Below is the snippet in config file
capabilities: {
'browserName': 'chrome',
'shardTestFiles': true,
'maxInstances': 3
},
specs: ['Spec1.js',
'Spec2.js',
'Spec3.js'
],
Any help can be appreciated.
Try adding count to the browser capabilities and maxSessions to the config file

How to run Protractor specs on IE 11?

I have been trying to run protractor specs on IE 11,with following conf.js:
multiCapabilities: [
{
'browserName': 'internet explorer',
version: 11,
'ignoreProtectedModeSettings': true
// 'idle-duration':10000,
},
}],
And added this as well:
seleniumArgs: 'C:/Users/LJQAuser/AppData/Roaming/npm/node_modules/protractor/node_modules/webdriver-manager/selenium/IEDriverServer.exe',
And set directConnect to : false
But still its showing error:
Error in console is:
[12:38:42] I/local - Starting selenium standalone server...
[12:38:43] E/launcher - Error: Error: Server terminated early with status 1
at earlyTermination.catch.e (C:\Users\LJQAuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\remote\index.js:252:52)
at :null:null
at process._tickCallback (internal/process/next_tick.js:188:7)
Closing report
[12:38:43] E/launcher - Process exited with error code 100
There is tons of issues with internet explorer. Probably you wont be able to run it successfully.
There is alot of manual steps also to be applied.
Here is some basic guide how to setup:
Protractor test in IE
https://qavalidation.com/2017/11/run-protractor-test-ie-internet-explorer.html/
Good luck!

Protractor test's within Webstorm has no Browser Connection

While trying to start the default protractor tests, WebStorm or protractor can not launch the default pages inside the Browser.
The Error Message is a simple Exception:
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
The setup for protractor is as follows:
The protractor.conf.js is as follows
exports.config = {
allScriptsTimeout: 11000,
specs: [
'*.js'
],
capabilities: {
'browserName': 'chrome'
},
baseUrl: 'http://localhost:8000/app/',
framework: 'jasmine2',
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};
and the tests are the default webstorm tests.
Configuration looks OK.
Please make sure you have started the local webserver on port 8000 (npm start) prior to running protractor - webserver needs to be serving up the application, so that Protractor can interact with it.
Also, make sure that web driver is installed (npm run update-webdriver)

why won't protractor recognize Angular ?

protractor is giving me errors telling me it can't find angular on the page. what else should I be considering to trouble shoot this ?
protractorConf.js
exports.config = {
seleniumAddress: 'http://0.0.0.0:4444/wd/hub',
capabilities: { 'browserName': 'chrome' },
specs: ['spec/javascripts/integration/main_spec.js'],
baseUrl: 'http://127.0.0.1:3000/',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
};
Failure message, a browser is actually opening, which is an improvement on where i was yesterday, any thoughts on this ?
jd#mbp ~/Dropbox/apps/lookingtolunch (master *)]$ protractor protractorConf.js
Using the selenium server at http://0.0.0.0:4444/wd/hub
F
Failures:
1) E2E: main page should find title element
Message:
Error: Angular could not be found on the page http://127.0.0.1:3000/ : angular never provided resumeBootstrap
Stacktrace:
Error: Angular could not be found on the page http://127.0.0.1:3000/ : angular never provided resumeBootstrap
at assertAngularOnPage (/usr/local/lib/node_modules/protractor/lib/protractor.js:668:13)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
==== async task ====
WebDriver.executeScript()
at Protractor.get (/usr/local/lib/node_modules/protractor/lib/protractor.js:675:15)
at null.<anonymous> (/Users/jd/Dropbox/apps/lookingtolunch/spec/javascripts/integration/main_spec.js:16:13)
at /usr/local/lib/node_modules/protractor/jasminewd/index.js:54:12
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
==== async task ====
at null.<anonymous> (/usr/local/lib/node_modules/protractor/jasminewd/index.js:53:12)
at null.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/minijasminenode/lib/async-callback.js:45:37)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
I am also getting the same problem, and since OP has gone silent, maybe I can use this answer space to give a second instance of the problem, and edit it to make it work based on other users feedback.
edit: I've found a solution. See edit at the bottom of the answer
I'm running Windows 8.1 running webdriver-manager start to launch Selenium standalone server, and python -m SimpleHTTPServer to host the site.
example-specs.js
describe("something peaceful", function() {
it("shouldn't be this hard", function() {
browser.get("http://127.0.0.1:8000"); // times out here
expect(true).toEqual(true);
});
});
conf.js
// protractor configuration for end-to-end (e2e) tests
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
capabilities: { 'browserName': 'chrome' },
specs: [ 'example-specs.js' ],
}
index.html
<!doctype html>
<html>
<body ng-app >
I can add: {{1+5}}.
<!-- script src="https://ajax.googleapis.com/ajax/libs/angularjs/**1.0.4**/angular.min.js"></script -->
<!-- Updated to 1.2.9 and the problem went away -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js"></script>
</body>
</html>
edit 1
I was running from WebStorm, but I also tried serving the site using python -m SimpleHTTPServer (and changing the address accordingly), but my results are the same.
edit 2
If I remove baseUrl and call browser.get(...) directly, I can get http://www.angularjs.org work, but not my local site, nor this jsfiddle angular app I found. Maybe it's just not working for automatic bootstrapping?
edit 3
Significantly reduced code to reproduce (removed controller). Moved script to the end of the body as recommended.
edit 4
I was using an old version (1.0.4) of Angular that appeared in this book. Upgrading to 1.2.9 (latest) fixed the problem.
If you need to navigate to a page which does not use Angular then Add this line of code before browser.get() line there:
browser.waitForAngularEnabled(false);
Reference : https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load