get current spec name and status in jasmine2 in protractor [duplicate] - javascript

This question already has answers here:
Jasmine2: get current spec name
(6 answers)
Closed 7 years ago.
I found jasmine.getEnv().currentSpec.description returns the name of the spec in the Jasmine1 version but doesn't work when switching to jasmine2 framework with protractor.
In my scenario I would like to capture screenshot for failure with spec name in after Each(). I am not sure how could I achieve this with jasmine2.
I know there is a package "protractor-html-screenshot-reporter" which can provide you the screenshot for failures. but I want to use the coding part here.
Hope you can help me to get a workaround for the same.
Thanks

If I'm reading correctly you want to have your spec name in your screenshot. If that's the case check the path builder section of the "protractor-html-screenshot-reporter" page on github.

Related

Symbol behind the .js [duplicate]

This question already has answers here:
Why pass parameters to CSS and JavaScript link files like src="../cnt.js?ver=4.0"?
(9 answers)
Closed 3 months ago.
What is "?_=3.5-SNAPSHOT-Dev" mean after ".js"? I do some research on google but no idea what it mean and what it use for
<script type="text/javascript" src="js/jquery-3.5.1.js?_=3.5-SNAPSHOT-Dev"></script>
It depends on the server that's serving your Javascript. Generally, variables like those on JS files are used for cache busting. I think in your example, 3.5-SNAPSHOT-Dev could be a release tag. If this JS file is now on your own machine, you can safely discard the ? and anything after that. If you're getting this from another server somewhere, seek out documentation about that server to see what they use the _ variable for.

Where can i find the code source of javascript functions? [duplicate]

This question already has answers here:
Where can I find javascript native functions source code? [duplicate]
(3 answers)
Closed 1 year ago.
For example, i want to know how the querySelector method was built. I checked on MDN but there's only examples that show how to use it.
I also tried to check in the console.log but nothing readable.
There is a non-standard method to do this. Please be aware that it is not fully cross-browser compatible and shouldn't be used in a production environment.
function hello(){
return "Hi!";
}
console.log(hello.toSource());
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toSource for more.
Edit:
To see the source code of a built-in function, you will need to look at the engine source. This varies browser to browser. For example, Chrome uses the V8 engine. See https://github.com/v8/v8

Mixpanel error: "mixpanel" object not initialized [duplicate]

This question already has answers here:
mixpanel-2-latest.min.js:9 Mixpanel error: "mixpanel" object not initialized
(7 answers)
Closed 5 years ago.
I am getting the below error.
I am using Angular - I have not imported a mix panel library - if I do a search I cannot find this.
Why am I getting this error/how can get rid of it?
Mixpanel error: "mixpanel" object not initialized. Ensure you are
using the latest version of the Mixpanel JS Library along with the
snippet we provide.
If you are not using mixpanel in your code, you should check whether it is one of your extensions.
In my case it was the PageRuler extension and started happening only today.
Check your extensions, for me it was 'Page Ruler'
["https://chrome.google.com/webstore/detail/page-ruler/jlpkojjdgbllmedoapgfodplfhcbnbpn?hl=nl"] that caused this error.
Disable all extensions until the error does not occur anymore.

How to debug JS calls [duplicate]

This question already has answers here:
JavaScript: Is there a way to get Chrome to break on all errors?
(5 answers)
Closed 6 years ago.
I'm trying to implement Metronic admin theme in my app, but when I click on a button, I get Empty string passed to getElementById(). and the buttons don't work.
I'm trying to track down which piece of code triggers this error. How can I find out where the problem is?
write debugger; right before the javascript code that you feel is troublesome. Also keep the inspect tools open (usually F12)
This will create a breakpoint in the code execution with which you can then debug your code and look for errors.

Angular adding "unsafe" to url when trying to download an file [duplicate]

This question already has answers here:
unsafe link in angular
(5 answers)
Closed 7 years ago.
I have a small AngularJS app where I am trying to open an uploaded image and am running into the issue where angular adds "unsafe:" at the beginning of the URL. I have added the following line in my app config to sanitize the URL, but it is not working for me:
$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|blob:chrome-extension):|data:image|\//);
I am using Angular v1.3.0 so I am using the correct property name. I am using Chrome mostly, but I have the same issue in other browsers. Also, the beginning of my image looks like this:
unsafe:data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUg...
Any idea what am I missing in my regex?
Thanks in advance!
If you $compileProvider.imgSrcSanitizationWhitelist() without the regexp parameter it returns the currently defined regexp .
Running this code on an empty angular 1.3.0:
app.config(function ($compileProvider) {
console.log($compileProvider.imgSrcSanitizationWhitelist()); //
});
I got this result - /^\s*((https?|ftp|file|blob):|data:image\/)/
And the base64 encoded JPEG using the basic <img ng-src="{{main.src}}"> actually works as you can see here, and another one with a png. Also look at the console to see the regexp.
Another test I've run is to move the data:image/jpeg;base64, out of the scope binded string and put it the ng-src:
<img ng-src="data:image/jpeg;base64,{{main.src}}">
As you can see it worked as well.
To make a long story short - you don't need to define a regexp in 1.3.0 and above for data:image/*, as it's defined by default.
I can't be sure what's the problem, but maybe you've got another definition of
imgSrcSanitizationWhitelist somewhere in your code or the data uri is broken somehow.

Categories

Resources