vsts-task-lib getvariable return null - azure-devops

I am trying to access vsts variables in my javascript code.I am using 'vsts-task-lib/task' library and getVariables() is returning null. This is what I have tried.
In package.json
"vsts-task-lib": "^2.4.0",
in javascript code
var tl = require('vsts-task-lib/task');
clientId = tl.getTaskVariable('My_KEY');

The getTaskVariable() function is used to get a variable value that is set by previous step from the same wrapper task, for example: tl.setTaskVariable('taskval1', 'val1value')
So, using getVariable(name) function instead.

Related

How to compare two locator value using chai assertion & serenity

I am new to Serenity and Protractor, so need your help for below query.
Using - Protractor, Chai assertion, Screenplay serenity, Cucumber, TypeScript
I have below 2 locators in my locator file:
static test1 = Target.the("test1).located(by.xpath(...**...);
static test2 = Target.the("test2).located(by.xpath(...**...);
I have to compare test1 and test2 values.
Steps.ts file:
expect(actor.toSee(Text.of(locatorClass.test1))).to.eventually.equal("21");
If I am passing some constant value, it's working. but I have to pass other locator. How can I compare this two locators?
I'm not familiar with serenityjs, but the problem is that you are trying to compare result of promise (getting text from test 1) with unresolved promise (getting text from test 1).
You have two possibilities:
1. Resolve both promises and compare values (using chai).
2. Resolve one of promises and compare value with another promise (using chai-as-promise).
Below you can see my proposal (2nd option). test1 promise is resolved and stored as test1text and than compared to the second promise.
static test1 = Target.the("test1).located(by.xpath(...**...);
static test2 = Target.the("test2).located(by.xpath(...**...);
return actor.toSee(Text.of(locatorClass.test1)).then((test1text) => {
return expect(actor.toSee(Text.of(locatorClass.test2))).to.eventually.equal(test1text);
});

broccoli-caching-writer fails with "Cannot read property 'images/.DS_Store' of undefined"

I am fairly new to broccoli and have been trying to write a simple plugin to use with ember.js. I used broccoli-caching-writer in my index.js as described on the github page for broccoli-caching-writer:
var CachingWriter = require('broccoli-caching-writer');
module.exports = CachingWriter.extend({
init: function(inputTrees, options)
{
console.log('Initializing plugin with tree');
console.log(inputTrees);
console.log(options);
this.inputTrees = inputTrees;
},
updateCache: function(srcPaths, destDir) {
console.log('updateCache called with srcPaths and destDir');
console.log(srcPaths);
console.log(destDir);
}
});
I then imported the plugin into my ember app (that uses ember CLI) and configured the following in my .brocfile
var plugin = require('broccoli-my-plugin');
var merge = require('broccoli-merge-trees');
pluginTree = new svgSpriter(['images'], {some: 'options'});
....
....
module.exports = merge([app.toTree(),pluginTree]);
Running the above with ember build command gives the following output (paths edited for privacy reasons):
Build failed.
Cannot read property 'images/.DS_Store' of undefined
TypeError: Cannot read property 'images/.DS_Store' of undefined
at CoreObject.proto.shouldBeIgnored (/node_modules/broccoli-svg-sprite/node_modules/broccoli-caching-writer/index.js:135:33)
at CoreObject.proto.keyForTree (/node_modules/broccoli-svg-sprite/node_modules/broccoli-caching-writer/index.js:277:14)
at CoreObject.<anonymous> (/node_modules/broccoli-caching-writer/index.js:267:21)
at Array.map (native)
at CoreObject.proto.keyForTree (/node_modules/broccoli-caching-writer/index.js:266:24)
at /node_modules/broccoli-caching-writer/index.js:87:20
at lib$rsvp$$internal$$tryCatch (/node_modules/broccoli-svg-sprite/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:489:16)
at lib$rsvp$$internal$$invokeCallback (/node_modules/broccoli-svg-sprite/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:501:17)
at lib$rsvp$$internal$$publish (/node_modules/broccoli-svg-sprite/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:472:11)
at lib$rsvp$asap$$flush (/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1290:9)
It seems like the plugin is trying to check whether to ignore the path or not, but the options passed to caching writer does not have filterfromcache option defined, so the above should work? Not sure if I'm missing something?
Any help would be appreciated.
Okay, I think the example for overriding the init method needs a little update for newbies like me.
It turns out that the init method in the parent module wasn't being called. Adding the following to my init method fixed it:
CachingWriter.prototype.init.call(this, inputTrees, options);
Not sure if there is a better way though.

undefine is not a function jquery auto complete

When trying to handle the data returned from autocomplete result set this always happens.
Any clue on this issue?
$("#search").autocomplete(suggest_url,{
max:100,
delay:10,
selectFirst: false
}).result(function(event, data, formatted)
{
do_search(true);
});
Thanks
Such error happens only if you are trying to call a function, but it is not a function.
x = 123;
x(); // produces «number is not a function
y = undefined;
y(); // produces exactly «TypeError: undefined is not a function»
«Uncaught type error» indicates that exception caused inside the lambla-style function. Thus, I hope, it is something wrong with do_searh identifier. Try to alert(do_searh) before calling it.
>>> UPDATE
This questions refers to another:
jQuery UI Autocomplete .result is not a function woes

Defining Window for Testing in Mocha

I'm trying to integrate some testing into my current Backbone/CoffeeScript application.
I have created a module for my application baked into the window object, but running any mocha tests fail because window is undefined.
module = (name) ->
window[name] = window[name] or {}
module 'Cart'
Any direction as to how I can define window for mocha?
I did try using jsdom and creating a window that way, but it still threw the same error. Thanks in advance.
EDIT:
Using zombie.js is getting me further then using jsdom.
zombie = require 'zombie'
browser = new zombie.Browser
browser.window.location = 'http://local.cart'
I'm trying to figure out a way to access the DOMWindow and set a variable to one of its values.
It would be ideal if browser.window was the same object as returned from accessing window in Chrome console, but it isn't.
I can access what I'm looking for with
zombie.visit 'http://local.cart', (err, browser) ->
throw err if err
browser.window.Cart
Is there a way for me to set what this returns to a global variable I can use throughout all of my specs?
Can't seem to get what I want trying a beforeEach or setting the previous block to a method and setting a variable to that method.
I think you'll definitely want to mock window, as opposed to trying to pass around a real DOM window object in the node side of your app (mocha).
Try this pattern I just whipped up (sort of conforms to mocha tutorials I have read and uses the this context which changes when in browser (window) vs. run on node (exports):
/**
* My namespace is 'AV'
*/
(function(root) {
/**
* #namespace root namespace object
*/
root['AV'] = root['AV'] || {};
var AV = root['AV'];
AV.CoolThing = {
//...
};
// this will give you
// your "window" object
// which is actually
// module.exports
return root;
})(this);
Then, the test might look something like this (mine are in coffeescript too):
chai = require 'chai'
chai.should()
# exports / "window"
{ AV } = require '../src/AV.js'
describe 'Sample test with namespace', ->
it 'should be an object', ->
AV.should.be.an 'object'

GWT Exporter - How do i create an instance of object at runtime. Object type will be available as a string argument

I am using the following code in GWT client
Inside my jsni method I am using the following code, Assume that typeName is String argument
typeName = '$wnd.mysample.SampleButton'
var sample = new window[typeName]();
sample.addButton(name, parent);
SampleButton implements Exportable class, I used #ExportPackage("mysample") and #Export(all = true).
In My entry module I called ExporterUtil.exportAll();
Note: if I replace
var sample = new $wnd.mysample.SampleButton() with new window[typeName]() then it is working fine otherwise it is throwing undefined function called.
Kindly let me know how to create an instance for the type in JSNI code
eval('var sample = $wnd.mysample.SampleButton();'); solves the issue.