Angular 2, Karma and PhantomJS - phantomjs

I am learning how to set up Karma with Angular 2 and running into issues.
I followed what Julie did in her seed project and applied it to my project.
All works well in Chrome, but when I want to use PhantomJS I get an error. This also happens in PhantomJS2...
This is the error:
[karma]: Karma v0.13.22 server started at http://localhost:9877/
[launcher]: Starting browser PhantomJS2
[PhantomJS 2.0.0 (Mac OS X 0.0.0)]: Connected on socket /#1yDrSei5NUX4_WYaAAAA with id 93476222
Missing error handler on `socket`.
TypeError: (msg || "").replace is not a function
at node_modules/karma/lib/reporter.js:45:23
karma.config.js
module.exports = function (config) {
config.set({
basePath : '',
frameworks : ['jasmine'],
files : [
// paths loaded by Karma
{pattern : 'node_modules/systemjs/dist/system-polyfills.js', included : true, watched : true},
{pattern : 'node_modules/systemjs/dist/system.src.js', included : true, watched : true},
{pattern : 'node_modules/es6-shim/es6-shim.js', included : true, watched : true},
{pattern : 'node_modules/angular2/bundles/angular2-polyfills.js', included : true, watched : true},
{pattern : 'node_modules/rxjs/bundles/Rx.js', included : true, watched : true},
{pattern : 'node_modules/angular2/bundles/angular2.js', included : true, watched : true},
{pattern : 'node_modules/angular2/bundles/testing.dev.js', included : true, watched : true},
{pattern : 'karma-test-shim.js', included : true, watched : true},
{pattern : 'app/**/*.js', included : false, watched : true},
{pattern : 'app/**/*.html', included : false, watched : true},
{pattern : 'app/**/*.css', included : false, watched : true},
{pattern : 'test/**/*.ts', included : false, watched : false},
{pattern : 'test/**/*.js', included : false, watched : true},
{pattern : 'test/**/*.js.map', included : false, watched : false}
],
proxies : {
"/app/" : "/base/src/app/"
},
reporters : ['progress'],
port : 9876,
colors : true,
logLevel : config.LOG_INFO,
autoWatch : false,
browsers : ['PhantomJS2'],
singleRun : true
})}
Anyone know what I am doing wrong?
Thanks in advance

ensure this line in your karma.conf.js
{pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: false, watched: false}, // PhantomJS2 (and possibly others) might require it
this github project works with phantom:
https://github.com/danday74/angular2-coverage/blob/master/karma.conf.js
clone it and have a play

Related

How do I include 'fs' modules in Sapper?

I am working on a Sapper project, as it seemed neat for a little project I wanted to get up and running quickly. That's not be easy and I'm now having trouble running scripts from my Sapper project that include the built-in 'fs' modules.
I'm trying to build a character generator. I have built a script that will do this but I'd like to be able to save my generated characters as JSON files then read them in later. Reading in is easy, writing doesn't seem to be listed anywhere obvious. The best I have is trying to get the built in plugins to function to allow me access to fs modules but my research on this is spotty and not helping. Trying to get rollup to help doesn't appear to work and I am unable to find an acceptable alternative.
Whenever I run the project, it just says that it can't resolve it.
Could not load fs (imported by E:\Software Projects\Javascript\Io-Generator\src\routes\generator\generator.js): ENOENT: no such file or directory, open 'E:\Software Projects\Javascript\Io-Generator\fs'
Nothing I do seems to help. Please can someone explain what I'm missing here? Am I using Sapper wrong? Am I missing something in rollup here? Is there an alternative I'm missing?
My roll-up config if it helps:
client: {
input: config.client.input(),
output: config.client.output(),
plugins: [
replace({
'process.browser': true,
'process.env.NODE_ENV': JSON.stringify(mode)
}),
svelte({
dev,
hydratable: true,
emitCss: true
}),
resolve({
browser: true,
preferBuiltins: true,
dedupe
}),
commonjs( {
browser: true
} ),
globals(),
builtins( {
fs: true
} ),
json(),
legacy && babel({
extensions: ['.js', '.mjs', '.html', '.svelte'],
runtimeHelpers: true,
exclude: ['node_modules/#babel/**'],
presets: [
['#babel/preset-env', {
targets: '> 0.25%, not dead'
}]
],
plugins: [
'#babel/plugin-syntax-dynamic-import',
['#babel/plugin-transform-runtime', {
useESModules: true
}]
]
}),
!dev && terser({
module: true
})
],
onwarn,
},
server: {
input: config.server.input(),
output: config.server.output(),
plugins: [
replace({
'process.browser': false,
'process.env.NODE_ENV': JSON.stringify(mode)
}),
svelte({
generate: 'ssr',
dev
}),
resolve({
browser: false,
preferBuiltins: true,
dedupe
}),
commonjs(),
builtins( {
fs: true
} ),
json()
],
external: Object.keys(pkg.dependencies).concat(
require('module').builtinModules || Object.keys(process.binding('natives'))
),
onwarn,
},
serviceworker: {
input: config.serviceworker.input(),
output: config.serviceworker.output(),
plugins: [
resolve( {
browser: false,
preferBuiltins: true
} ),
replace({
'process.browser': true,
'process.env.NODE_ENV': JSON.stringify(mode)
}),
commonjs(),
builtins( {
fs: true
} ),
json(),
!dev && terser()
],
onwarn,
}
};```
So, I went an restarted my project from a fresh project. Aaaaand it was fine. It's working fine. It's possible that I really screwed up my project trying out multiple different things to get them working, causing some serious damage. I'll need to be more careful in future.

How to use four_button.js plugin in Datatables 1.10

I'm start to use Datatables 1.10 versiĆ³n but i have problems to use this option "sPaginationType" : 'four_button' when initializing my datatables
In the version 1.9.4 , I used previously works correctly
My datatables version
https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js
My four_button version
https://cdn.datatables.net/plug-ins/1.10.17/pagination/four_button.js
table = $('#tabla-informes').DataTable({
"sDom" : "",
"sPaginationType" : 'four_button',
"aoColumns" : aoColumns,
"aoColumnDefs" : [ {"bVisible" : false, "aTargets" : [ 0 ]} ],
"bServerSide" : true,
"sAjaxSource" : "/informacion/ajaxLista",
"fnServerParams": function ( aoData ) {
}) ....
Browser crash
https://imgur.com/YnNlXoj
Thanks, all

ELK - X-Pack Custom realm

I've developed a custom realm for my ELK cluster.
This module works well on a on node elasticsearch but when I install it on my production cluster, nothing works.
Elasticsearch starting logs :
- nothing special, everything seems to work and xpack module is loaded (generates a log in stdout)
Elasticsearch cluster diagnostic (custom seems to be disabled and not available) :
{
"security" : {
"available" : true,
"enabled" : true,
"realms" : {
"file" : {
"available" : true,
"enabled" : false
},
"ldap" : {
"available" : true,
"enabled" : false
},
"native" : {
"name" : [
"realm2"
],
"available" : true,
"size" : [
2
],
"enabled" : true,
"order" : [
1
]
},
"custom" : {
"available" : false,
"enabled" : false
},
...
}
Elasticsearch configuration :
cluster.name: "production-cluster-1"
network.host: 0.0.0.0
bootstrap.memory_lock: true
xpack.security.enabled: true
xpack.security.audit.enabled: true
xpack.monitoring.enabled: true
xpack.graph.enabled: false
xpack.watcher.enabled: false
xpack.ml.enabled: false
discovery.zen.ping.unicast.hosts: "-------------------"
network.publish_host: "----"
discovery.zen.minimum_master_nodes: 3
xpack.security:
authc:
realms:
realm1:
type: custom
order: 0
realm2:
type: native
order: 1
The native authentication works fine.
How can I troubleshoot this correctly ? :)
Thanks
Let's start by turning up the logging:
curl -u<user> -XPUT '<host>:<http-port>/_cluster/settings?pretty' -H 'Content-Type: application/json' -d'
{
"transient": {
"logger.org.elasticsearch.xpack.security.authc": "DEBUG"
}
}
'
That will give you any authentication logs on debug. I think the right package for the native realm should be logger.org.elasticsearch.xpack.security.authc.esnative in case you want to limit it down just to that.

JSlint ignoring globals set inside .jshintrc file - used in intellij

I am trying to use jshint and jslint.I am using custom .jshintrc file and add few of my global variables and functions into globals inside .jshintrc as below.
{
// Environments
"browser" : true, // Web Browser (window, document, etc)
"browserify" : false, // Browserify (node.js code in the browser)
"couch" : false, // CouchDB
"devel" : true, // Development/debugging (alert, confirm, etc)
"dojo" : false, // Dojo Toolkit
"jasmine" : false, // Jasmine
"jquery" : true, // jQuery
"mocha" : true, // Mocha
"mootools" : false, // MooTools
"node" : true, // Node.js
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
"phantom" : false, // PhantomJS
"prototypejs" : false, // Prototype and Scriptaculous
"qunit" : false, // QUnit
"rhino" : false, // Rhino
"shelljs" : false, // ShellJS
"typed" : false, // Globals for typed array constructions
"worker" : false, // Web Workers
"wsh" : false, // Windows Scripting Host
"yui" : false, // Yahoo User Interface
"globals": {
"swal": true,
"testvar1":true,
"testfunction1":true,
"testfunction2":true,
"testvar2":true,
"console":true,
"$":true
}
}
I am getting following errors
JSLint:Undeclared console
JSLint:Undeclared $
When I add /*gloabls console */ in same file it is working fine.How to fix this issue.
Thanks

Adjusting User Context with TreeStoreBuilder

I've been able to create a grid and basic filtering to narrow down iterations etc. Ideally I would like to run this via html/confluence so ideally I need to have the filtering set so that I can filter on parent as well as project. Testing this in the Rally dashboard, the way I have it still only working within project I'm sitting in. How do I make my filtering work so that where I'm at project wise in Rally doesn't matter or if I use my api key.
Thanks!
Mark
Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({
models: ['userstory'],
autoLoad: true,
enableHierarchy: true,
filters: [{property: 'Iteration.Name',
operator : '=',
value : 'March'},
{property: 'Project.Parent.Name',
operator : '=',
value : 'Synergy'},
{property: 'Project.Name',
operator : '=',
value : 'Condor'}
]
}).then({
success: function(store) {
Ext.create('Ext.Container', {
items: [{
xtype: 'rallytreegrid',
columnCfgs: [
'DisplayColor',
'Name',
'ScheduleState',
'Blocked',
'TaskEstimateTotal',
'TaskRemainingTotal',
'Owner',
'Notes'
],
store: store
}],
renderTo: Ext.getBody()
});
}
});
You just need to pass a context to your store:
https://help.rallydev.com/apps/2.0/doc/#!/guide/data_stores-section-scoping
All projects:
{ project: null, workspace: '/workspace/12345'}
Specific project:
{ project: '/project/12345', projectScopeDown: false, projectScopeUp: false }
Project hierarchy:
{ project: '/project/12345', projectScopeDown: true, projectScopeUp: false }
Or if you are trying to get data from multiple projects not in a tree you can always create a filter in the store on Project like you're doing above. Note that you'll need to make sure all those projects are actually in scope based on your context to get any results.