I'm trying to create the Leaderboard on Cloud9. But I get the error: PlayersList not defined... in the editor. The app is working, but then it's code in editor underlining all 'not defind PlayersList'
The code:
PlayersList = new Mongo.Collection('players');
if(Meteor.isClient){
Template.leaderboard.helpers({
'player': function(){
return PlayersList.find({}, {sort: {score: -1, name: 1}});
},
'selectedClass': function(){
var playerId = this._id;
var selectedPlayer = Session.get('selectedPlayer');
if(selectedPlayer === playerId){
return 'selected';
}
},
'showSelectedPlayer': function(){
var selectedPlayer = Session.get('selectedPlayer');
return PlayersList.findOne(selectedPlayer);
}
});
Cloud9's editor uses ESLint, and using foo = 22 makes it think that there's a missing statement like var foo; somewhere. You can either choose to ignore this, or fix it as follows:
Add /*eslint-env meteor */ to the top so it doesn't give warnings about Meteor globals, and maybe you'll also need to add /* globals Player */ added too in case the error still stays. (I haven't tested this out, please let me know how it goes so I can improve the answer)
I solved the problem with a little workaround. I added coffeescript and then I used the # symbol on the global like you should, when you define a collection with coffeescript. And that was solving it for me. It works fine. As I opened the app in an new browser window, posts were available in the console.
Example:
#Posts = new Mongo.Collection('posts')
Related
I'm unable to get value from h2 tag using protractor.
Html Code:
<h2 class="ng-binding">7</h2>
I need this 7 value. This is from website "http://juliemr.github.io/protractor-demo/". I am adding 5+2.
Appreciate your help.
Try xpath
Here I am getting the element with ID, moving one position back and then looking for the h2
var result = element(by.xpath('//*[#id=\'gobutton\']/../h2'))
result.getText().then(function(value){
expect(value).toBe('7');
})
Or look directly to the h2:
element(by.xpath('//h2[#class='ng-binding']'))
In case you plan to always have 7 as a result then you can also look for the cssContainingText
var result = element.all(by.cssContainingText('.ng-binding', '7')).first();
in this case I am using .all and .first because this will return 2 elements so I am telling protractor to use always the first one
So your code should be something like this:
it('Should access the page and perform sum', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
element(by.model('first')).sendKeys(5);
element(by.model('second')).sendKeys(2);
element(by.id('gobutton')).click();
var result = element(by.xpath('//*[#id=\'gobutton\']/../h2'))
result.getText().then(function(value){
console.log('result is '+value)
expect(value).toBe('7');
})
});
As per the url given, After clicking Go it loads for some time. So add some wait and then try to getText() with the below locator.
browser.sleep(5000);
element(by.css('form>h2.ng-binding')).getText().then((text: String) =>{
expect(text).toBe("7");
})
Hope it helps you...
First, you find the element, for example with a by.css call. Then you use getText method to retrieve the desired tag content. Finally, you assert it to be equal to the value you expect:
result = element(by.css('h2.ng-binding'))
expect(result.getText()).toEqual('7')
Well, the question is very self-explanatory.
Right now, I'm front of a form which has a select tag with a couple of options already. But I must insert a new one, with a different value that I will receive from a .json file.
The thing is: I haven't been able to find a suitable solution from the CasperJS documentation.
I've tried something like this:
this.fill('form.coworkerdiscountcode', {
'CoworkerDiscountCode.DiscountCode': ['Value1']
});
But no results. Any ideas?
Thanks in advance.
You can execute any javascript code by passing it to casper.evaluate like this:
casper.evaluate(function() {
var x = document.getElementById("coworkerdiscountcode");
var option = document.createElement("option");
option.text = "Kiwi";
x.add(option);
});
I am writing a protractor test case to compare the name(s) of the displayed data is same as the searched name.
Even though my test case works fine, I am not able to understand what is happening. Because when i expect the name to compare, it compares as expected, but when i print the elementFinder's(rowData)(i have attached the output screen shot here) value in console.log, it show a huge list of some values which i am not able to understand?
PS: I am a newbie to protractor`
This is the testCase:
it('should show proper data for given last name', function () {
var searchValue='manning';
searchBox.sendKeys(searchValue);
search.click();
element.all(by.binding('row.loanNumber')).count().then(function(value) {
var loanCount = value;
for (var i = 0; i < loanCount; i++) {
var rowData = element.all(by.binding('row.borrowerName')).get(i).getText();
expect(rowData).toMatch(searchValue.toUpperCase());
console.log(rowData,'*****',searchValue.toUpperCase());
}
});
});`
And give me valuable suggestions about my style of code
rowData is a promise (not a value), so when you console.log it, you get the promise object
Protractor patches Jasmine to automatically resolve promises within the expect(), so that's how it knows to resolve the value and compare to the expected result.
If you want to console.log the value, you need to resolve the promise with .then() to get the value.
rowData.then(function(rowDataText) {
console.log(rowDataText);
)}
This is pretty much everyone's first question when they start using protractor. You will want to learn how promises work if you want a good understanding of how to manipulate them.
I'm trying to create a plugin for JSDoc.
I'm following the documentation (which, ironically, is lacking) and I'm not sure how to do this.
My plugin is loaded properly, and I'm trying a simple example. Here's my plugin (which loads, because I can throw an error from there to stop jsdoc from running):
visitNode: function(node, e, parser, currentSourceName) {
if(node.type === 109){
if(!e.comment || e.comment ==="#undocumented"){
var startComment = '/**',
endComment = '\n*/';
var params = node.getParams(),
paramsComment = '';
for(var i=0; i<params.length; i++){
paramsComment += '\n* #param ' + params[i];
}
e.comment = startComment +
paramsComment +
endComment;
}
}
please note that node.type === 109 is equivalent to Token.FUNCTION, which should be available as per their example here, but Token is undefined in the plugin.
If you know of a better site which explains how to write a JSDoc plugin, then that would be very much appreciated too... thanks
I also had this problem and it seems strange that JSDoc does not have some kind of already made option for that or at least a plugin.
Anyway creating this plugin has solved my problem. I am using JSDoc version 3.4:
'use strict';
exports.handlers = {
symbolFound:function(e) {
if(e.astnode.type === "FunctionDeclaration" ) {
if( (e.comment==="#undocumented")){
e.comment = '/** undocumented */';
}
}
}
};
I am using Mongodb(c#) in my WPF App.
I wrote query as
var server = MongoServer.Create(this.connectionString);
var db = server.GetDatabase(DATABASE);
var loadRiskAlertTypeSettings = db.GetCollection(RISKALERTSETTINGS_TBL);
var qry = Query.EQ("UserName", ConsoleMain.lblUname.Content.ToString());
List<RiskAlertTypeSettings> userResult = loadRiskAlertTypeSettings.FindAs<RiskAlertTypeSettings>(qry).ToList<RiskAlertTypeSettings>();
But it did not showing ToList<> property in my current working window.
I used above query in my App several times in different windows.
But in my present window it did not showing?
I traced.But i did not find any solution.
Can any one guide me in that?
I've tested your code and I don't see any problem for doing this:
var userResult = loadRiskAlertTypeSettings
.FindAs<RiskAlertTypeSettings>(qry)
.ToList();
The method ToList() is in System.Linq namespace, so check if you imports have included it.
using System.Linq;