Phantom manager could not start all workers - express

I trying to create a pdf using phamton-html-to-pdf and ejs for templating. The setup work greate in my local dev env, but not in production. The problem is that in my server prod the pdf is created but it is empty.
const ejs = require('ejs');
const fs = require('fs');
const conversion = require("phantom-html-to-pdf")({
phantomPath: require("phantomjs-prebuilt").path
});
function createPdf (data, template, directory) {
var options = {};
var html = ejs.renderFile(__dirname + `/template/${template}.ejs`, {data: data}, options, function(err, str){
if(err){
return err
}
return str
});
var filepath = null
conversion({ html: html, printDelay: 5000}, (err, pdf) => {
var output = fs.createWriteStream(`documents/${directory}/${data.Référence}.pdf`)
pdf.stream.pipe(output);
});
}
module.exports = createPdf;
{ Error: phantom manager could not start all workers..
at /home/website/group-auto.com/node_modules/phantom-workers/lib/phantomManager.js:66:47
at /home/website/group-auto.com/node_modules/phantom-workers/lib/phantomWorker.js:115:24
at /home/website/group-auto.com/node_modules/phantom-workers/lib/phantomWorker.js:140:20
at Socket.<anonymous> (/home/website/group-auto.com/node_modules/phantom-workers/lib/checkPortStatus.js:45:9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at TCP._handle.close [as _onclose] (net.js:497:12)
[ { Error: Command failed: /home/website/group-auto.com/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any /home/website/group-auto.com/node_modules/phantom-html-to-pdf/lib/scripts/serverScript.js
/home/website/group-auto.com/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs: 1: /home/website/group-auto.com/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs: Syntax error: word unexpected (expecting ")")
at ChildProcess.exithandler (child_process.js:198:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:920:16)
at Socket.<anonymous> (internal/child_process.js:351:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:497:12)
killed: false,
code: 2,
signal: null,
cmd: '/home/website/group-auto.com/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any /home/website/group-auto.com/node_modules/phantom-html-to-pdf/lib/scripts/serverScript.js' },
I have no idea where to look for error, please help

You have to install 'libfontconfig' in your server.
macOS sierra update works only with phantomjs2.
linux may need to additionally install fontconfig package.
Centos - sudo yum install -y fontconfig
Debian/Ubuntu - sudo apt-get install -y libfontconfig

I had this problem with phantom-html-to-pdf (0.5.6).
In my case, my config was :
const pdf = require("phantom-html-to-pdf")({
// number of allocated phantomjs processes
numberOfWorkers: 3,
// timeout in ms for html conversion, when the timeout is reached, the phantom process is recycled
timeout: 10000,
// directory where are stored temporary html and pdf files
tmpDir: __dirname + "/tmp/",
phantomPath: "/usr/bin/phantomjs"
});
But my phantomPath was useless cause they're no executable at phantomPath in my case (we propably remove it for some reasons).
const pdf = require("phantom-html-to-pdf")({
// number of allocated phantomjs processes
numberOfWorkers: 3,
// timeout in ms for html conversion, when the timeout is reached, the phantom process is recycled
timeout: 10000,
// directory where are stored temporary html and pdf files
tmpDir: __dirname + "/tmp/"
});
My config without phantomPath works !

Related

PHPLint: Error thrown using PHPLint but not with PHP

I'm using the PHPLint NPM package with Gulp but am getting a PHP error when I run it. When I run the failed command with PHP, I do not receive the error.
The task runs successfully without any errors in the files I'm linting, so I can't think of issues with gulp.
php.ini has error reporting enabled:
error_reporting = E_ALL
display_errors = On
Command using PHPLint:
$ gulp phplint
[17:38:24] Using gulpfile C:\laragon\www\wp\wp-content\plugins\wp-plugin-jumpstart\gulpfile.js
[17:38:24] Starting 'phplint'...
[17:38:24] 'phplint' errored after 102 ms
[17:38:24] Error: Command failed: php -d display_errors=1 -l classes/Get_Started.php
at ChildProcess.exithandler (node:child_process:397:12)
at ChildProcess.emit (node:events:390:28)
at ChildProcess.emit (node:domain:537:15)
at maybeClose (node:internal/child_process:1064:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
at Process.callbackTrampoline (node:internal/async_hooks:130:17)
Running that failed command through PHP:
$ php -d display_errors=1 -l classes/Get_Started.php
Parse error: syntax error, unexpected 'class' (T_CLASS) in classes/Get_Started.php on line 5
Errors parsing classes/Get_Started.php
gulp.js
gulp.task('phplint', function (cb) {
phplint(['**/*.php', '!vendor/**', '!node_modules/**'], { limit: 10 }, function (err, stdout, stderr) {
if (err) {
cb(err);
process.exit(1);
}
cb();
console.log('PHP Linted Successfully');
});
});

"Connection refused! Is selenium server started?" error in VueJS Nightwatch E2E tests using ChromeDriver and Chrome

I have a VueJS app that has the default Nightwatch E2E tests. I just spent some time getting user accounts and auth set up. After doing so, when I try to run my E2E tests, they fail mysteriously. Here's the command line output I get:
code/premium-poker-tools [master●] » npm run e2e
> premium-poker-tools#1.0.0 e2e /Users/adamzerner/code/premium-poker-tools
> node test/e2e/runner.js
> Starting dev server...
Starting to optimize CSS...
> Listening at http://localhost:8080
Starting selenium server... started - PID: 58502
[BABEL] Note: The code generator has deoptimised the styling of "/Users/adamzerner/code/premium-poker-tools/test/e2e/specs/hit-calculator.js" as it exceeds the max of "500KB".
player
1
2
3
1) "before all" hook
0 passing (2s)
1 failing
1) player "before all" hook:
Connection refused! Is selenium server started?
npm ERR! code ELIFECYCLE
npm ERR! errno 10
npm ERR! premium-poker-tools#1.0.0 e2e: `node test/e2e/runner.js`
npm ERR! Exit status 10
npm ERR!
npm ERR! Failed at the premium-poker-tools#1.0.0 e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/adamzerner/.npm/_logs/2019-05-23T19_47_08_016Z-debug.log
code/premium-poker-tools [master●] »
And here is /Users/adamzerner/.npm/_logs/2019-05-27T17_44_07_557Z-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/11.11.0/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'e2e' ]
2 info using npm#6.9.0
3 info using node#v11.11.0
4 verbose run-script [ 'pree2e', 'e2e', 'poste2e' ]
5 info lifecycle premium-poker-tools#1.0.0~pree2e: premium-poker-tools#1.0.0
6 info lifecycle premium-poker-tools#1.0.0~e2e: premium-poker-tools#1.0.0
7 verbose lifecycle premium-poker-tools#1.0.0~e2e: unsafe-perm in lifecycle true
8 verbose lifecycle premium-poker-tools#1.0.0~e2e: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/adamzerner/code/premium-poker-tools/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/adamzerner/.rvm/bin
9 verbose lifecycle premium-poker-tools#1.0.0~e2e: CWD: /Users/adamzerner/code/premium-poker-tools
10 silly lifecycle premium-poker-tools#1.0.0~e2e: Args: [ '-c', 'node test/e2e/runner.js' ]
11 silly lifecycle premium-poker-tools#1.0.0~e2e: Returned: code: 10 signal: null
12 info lifecycle premium-poker-tools#1.0.0~e2e: Failed to exec e2e script
13 verbose stack Error: premium-poker-tools#1.0.0 e2e: `node test/e2e/runner.js`
13 verbose stack Exit status 10
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:197:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:197:13)
13 verbose stack at maybeClose (internal/child_process.js:984:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
14 verbose pkgid premium-poker-tools#1.0.0
15 verbose cwd /Users/adamzerner/code/premium-poker-tools
16 verbose Darwin 18.6.0
17 verbose argv "/usr/local/Cellar/node/11.11.0/bin/node" "/usr/local/bin/npm" "run" "e2e"
18 verbose node v11.11.0
19 verbose npm v6.9.0
20 error code ELIFECYCLE
21 error errno 10
22 error premium-poker-tools#1.0.0 e2e: `node test/e2e/runner.js`
22 error Exit status 10
23 error Failed at the premium-poker-tools#1.0.0 e2e script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 10, true ]
For one, the Connection refused! Is selenium server started? error seems wrong. Above that it says Starting selenium server... started - PID: 58502, and I see a Chrome browser pop up very briefly and then immediately close.
Here is the code for the before block in question:
before(function (browser, done) {
console.log(1);
equityCalculator = browser.page['equity-calculator']();
console.log(2);
equityCalculator.navigate();
console.log(3);
browser.pause(20000);
equityCalculator
.waitForElementVisible('#app', 50000, function () {
console.log(4);
browser.resizeWindow(1440, 852, function () {
console.log(5);
done();
});
})
;
});
I've been trying to pin down where the problem occurs, but I'm having a lot of trouble. 1, 2, and 3 get logged out, but not 4 or 5, so that helps. But if 3 gets logged out, why isn't browser.pause(20000) working?
I've also been trying to mess around in my actual code to see where the issue is. I tried some alert statements in main.js to try to pinpoint the issue:
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
alert(1);
window.$ = require('jquery');
require('bootstrap');
alert(2);
import Vue from 'vue';
import store from '#/store';
import App from './App';
import router from './router';
import monkeyPatches from '#/services/monkey-patches';
import axios from 'axios';
import VueAxios from 'vue-axios';
alert(3);
Vue.config.productionTip = false
Vue.use(VueAxios, axios);
axios.interceptors.request.use(
function(config) {
config.withCredentials = true;
return config;
},
function(error) {
return Promise.reject(error);
}
);
/* eslint-disable no-new */
new Vue({
el: '#app',
router: router,
store: store,
template: '<App/>',
components: { App }
});
$(function () {
$('[data-toggle="popover"]').popover();
});
// if (navigator.serviceWorker) {
// navigator.serviceWorker.register('/service-worker.js').catch(function() {
// console.log('Service worker registration failed.');
// });
// }
But weirdly, alert(1) isn't even working. So I feel at a loss. From what I understand, the top of main.js is the "beginning" of a Vue app, and if it's not even reaching that point, what is going on? equityCalculator = browser.page['equity-calculator'](); and equityCalculator.navigate(); seem pretty standard. Here's a snippet of the page object:
module.exports = {
url: 'http://localhost:8080/equity-calculator',
elements: {
'app': '#app',
When I start my dev server and go to that url, it totally works. And my E2E tests were all working perfectly before I implemented user accounts and auth, I didn't change this file, and yet now I'm having the issue.
I'm not sure where I can go from here. Help!
Update:
Excerpt from package.json:
{
...
"dependencies": {
...
"chromedriver": "^2.45.0",
"cross-spawn": "^6.0.5",
"nightwatch": "^0.9.21",
"selenium-server": "^3.141.59",
},
}
Here's nightwatch.conf.js:
require('babel-register')
let config = require('../../config')
// http://nightwatchjs.org/gettingstarted#settings-file
module.exports = {
src_folders: ['test/e2e/specs'],
output_folder: 'test/e2e/reports',
custom_assertions_path: ['test/e2e/custom-assertions'],
page_objects_path: 'test/e2e/page-objects',
globals_path: 'test/e2e/globals.js',
test_runner : 'mocha',
selenium: {
start_process: true,
server_path: require('selenium-server').path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': require('chromedriver').path
}
},
test_settings: {
default: {
selenium_port: 4444,
selenium_host: 'localhost',
silent: true,
globals: {
devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port),
handStrings: [
'aa', 'aks', 'aqs', 'ajs', 'ats', 'a9s', 'a8s', 'a7s', 'a6s', 'a5s', 'a4s', 'a3s', 'a2s',
'ako', 'kk', 'kqs', 'kjs', 'kts', 'k9s', 'k8s', 'k7s', 'k6s', 'k5s', 'k4s', 'k3s', 'k2s',
'aqo', 'kqo', 'qq', 'qjs', 'qts', 'q9s', 'q8s', 'q7s', 'q6s', 'q5s', 'q4s', 'q3s', 'q2s',
'ajo', 'kjo', 'qjo', 'jj', 'jts', 'j9s', 'j8s', 'j7s', 'j6s', 'j5s', 'j4s', 'j3s', 'j2s',
'ato', 'kto', 'qto', 'jto', 'tt', 't9s', 't8s', 't7s', 't6s', 't5s', 't4s', 't3s', 't2s',
'a9o', 'k9o', 'q9o', 'j9o', 't9o', '99', '98s', '97s', '96s', '95s', '94s', '93s', '92s',
'a8o', 'k8o', 'q8o', 'j8o', 't8o', '98o', '88', '87s', '86s', '85s', '84s', '83s', '82s',
'a7o', 'k7o', 'q7o', 'j7o', 't7o', '97o', '87o', '77', '76s', '75s', '74s', '73s', '72s',
'a6o', 'k6o', 'q6o', 'j6o', 't6o', '96o', '86o', '76o', '66', '65s', '64s', '63s', '62s',
'a5o', 'k5o', 'q5o', 'j5o', 't5o', '95o', '85o', '75o', '65o', '55', '54s', '53s', '52s',
'a4o', 'k4o', 'q4o', 'j4o', 't4o', '94o', '84o', '74o', '64o', '54o', '44', '43s', '42s',
'a3o', 'k3o', 'q3o', 'j3o', 't3o', '93o', '83o', '73o', '63o', '53o', '43o', '33', '32s',
'a2o', 'k2o', 'q2o', 'j2o', 't2o', '92o', '82o', '72o', '62o', '52o', '42o', '32o', '22',
],
}
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true
}
}
}
}
And for Java/JDK:
code/premium-poker-tools-api [master] » java --version
java 9.0.4
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
When I look in my Java Control Panel, it says that I'm up to date.
I'm not sure how to figure out which Selenium version or Chrome version I'm using. For Chrome, if I open up Chrome and go to "About Google Chrome" it says 74.0.3729.169, the up to date one, and I assume my tests are using that same version.
This log message...
Starting selenium server... started - PID: 58502
and the subsequent error message...
Connection refused! Is selenium server started?
...implies that the WebDriver instance i.e. ChromeDriver though initiated but was unable to communicate with the WebBrowsing i.e. Chrome session.
Some more details about the:
Selenium version.
JDK version.
Selenium Server mode (Standalone/Grid).
ChromeDriver version.
Chrome version.
Would have helped us to debug the issue in a better way. However as you have mentioned "1, 2, and 3 get logged out, but not 4 or 5", possibly the issue stems out from the following code block:
equityCalculator
.waitForElementVisible('#app', 50000, function () {
console.log(4);
browser.resizeWindow(1440, 852, function () {
console.log(5);
done();
});
})
Reason
As per the discussion Connection refused! Is selenium server started nightwatch on edge your main issue seems to be incompatibility between the version of the binaries you are using.
Solution
Upgrade JDK to recent levels JDK 8u212.
Upgrade Selenium to current levels Version 3.141.59.
Upgrade ChromeDriver to ChromeDriver v74.0 level.
Upgrade Chrome version to Chrome v74 levels. (as per ChromeDriver v74.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
Outro
'Connection refused! Is selenium server started?\n' while running Nightwatch.js tests against Selenium Grid
Resolution
updating npm resolved the issue (as per OP's comments)
npm update

ReferenceError: ReadableStream is not defined while running jest tests

My web app reads local files using a custom ReadableStream (in-order that I won't need to have a max file size that the platform supports) and it works great, both for correctly formatted files and error files. My app is built using React-Redux-Saga.
I'm now attempting to add limited e2e tests to my code to test the state management. I'm testing that when sending redux actions the state updates correctly. I'm testing the saga's using the package redux-saga-tester.
While running the jest client tests that read local files using the ReadableStream I built, I got an error ReferenceError: ReadableStream is not defined. What I understood is that the jsdom environment that jest uses is missing the ReadableStream implementation. I than added the web-streams-polyfill package to polyfill the ReadableStream class.
Now the validate file test is passing as in the browser:
test('Select and validate log file', async () => {
const testFile = testFileBuilder.valid();
storeTester.dispatch(fileSelected(testFile));
await storeTester.waitFor(FILE_VALIDATED);
const state = storeTester.getState().file;
expect(state.fileValidated).toBeTruthy();
});
My problem is that when I run a second validation test with an invalid file the test passes but prints an error to the console.
The test:
test('Select an invalid file - JSON error', async () => {
const testFile = testFileBuilder.errorJSON();
storeTester.dispatch(fileSelected(testFile));
await storeTester.waitFor(FILE_ERROR);
const state = storeTester.getState().file;
expect(state.fileValidated).toBeFalsy();
expect(state.fileError).toBeTruthy();
});
The error that is printed after the test completes successfully:
e.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
Error: Error: connect ECONNREFUSED 127.0.0.1:80
at Object.dispatchError (/home/noams/dev/web/visual-log-viewer/client/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:65:19)
at Request.client.on.err (/home/noams/dev/web/visual-log-viewer/client/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:676:20)
at Request.emit (events.js:194:15)
at Request.onRequestError (/home/noams/dev/web/visual-log-viewer/client/node_modules/request/request.js:881:8)
at ClientRequest.emit (events.js:189:13)
at Socket.socketErrorListener (_http_client.js:392:9)
at Socket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19) undefined
Any subsequent file validation tests fail.
I'd appreciate any advice of how to tackle this issue.

Error: no writecb in Transform class.?

Good day. Help me please.
There are some versions.
npm v3.10.6
node v4.5.
"gulp-file-include": "^0.14.0",
"gulp-remove-html": "^1.1.2"
There is part of gulpfile.js
fileinclude = require('gulp-file-include'),
gulpRemoveHtml = require('gulp-remove-html')
gulp.task('buildhtml', function() {
gulp.src(['app/*.html'])
.pipe(fileinclude({
prefix: '##'
}))
.pipe(gulpRemoveHtml())
.pipe(gulp.dest('dist/'));
});
There is result after running "gulp buildhtml". The problem appears today.
[11:31:46] Starting 'buildhtml'... [11:31:46] Finished 'buildhtml' after 8.83 ms events.js:141
throw er; // Unhandled 'error' event
^
Error: no writecb in Transform class
at afterTransform (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:74:40)
at TransformState.afterTransform (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:58:12)
at DestroyableTransform.fileInclude [as _transform] (C:\Projects\Projects\project1\node_modules\gulp-file-include\lib\index.js:49:9)
at DestroyableTransform.Transform._read (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:159:10)
at DestroyableTransform.Transform._write (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:147:83)
at doWrite (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:313:64)
at writeOrBuffer (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:302:5)
at DestroyableTransform.Writable.write (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:241:11)
at write (C:\Projects\Projects\project1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:623:24)
at flow (C:\Projects\Projects\project1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (C:\Projects\Projects\project1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:664:5)
at emitNone (events.js:67:13)
at DestroyableTransform.emit (events.js:166:7)
at emitReadable_ (C:\Projects\Projects\project1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:448:10)
at emitReadable (C:\Projects\Projects\project1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:444:5)
at readableAddChunk (C:\Projects\Projects\project1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:187:9)
If you use Gulp 4.0 alpha 3, Downgrade to Gulp 4.0 alpha 2 with
npm install -S gulpjs/gulp#6d71a65

WebStorm: Karma server not starting, TypeError: undefined is not a function on server.start();

I have the latest version of WebStorm (10.0.4). Today I wanted to include karma in my project so I installed Python and ran:
npm install -g karma
npm install karma
npm install karma-jasmine
npm install karma-chrome-launcher
npm install karma-phantomjs-launcher
I tried it with two different config files, one for my project and one superbasic config, but both throw the same error. Here is the basic config:
// Karma configuration
// Generated on Fri Jul 17 2015 14:05:46 GMT+0200 (Mitteleuropäische Sommerzeit)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'test/**/*Spec.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
})
}
I then created a new "Karma" Run configuration, but when I click run, it says:
"C:\Program Files\nodejs\node.exe" "C:\Program Files (x86)\JetBrains\WebStorm 10.0.4\plugins\js-karma\js_reporter\karma-intellij\lib\intellijServer.js" --karmaPackageDir=C:\workspace\full_ui\node_modules\karma --configFile=C:\workspace\full_ui\tests\karma.conf_messages.js --browsers=Chrome
C:\Program Files (x86)\JetBrains\WebStorm 10.0.4\plugins\js-karma\js_reporter\karma-intellij\lib\intellijServer.js:10
server.start(cliOptions);
^
TypeError: undefined is not a function
at Object.<anonymous> (C:\Program Files (x86)\JetBrains\WebStorm 10.0.4\plugins\js-karma\js_reporter\karma-intellij\lib\intellijServer.js:10:8)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
Process finished with exit code 1
I really don't know what could cause this problem. Did I miss anything to install? I have never used karma before, so I might have some basic error somewhere, but I can't figure out what.
I think this may be caused by a recent update to the karma lib 9 days ago
https://github.com/karma-runner/karma/commits/master/lib/server.js
It could be the intellijServer.js is now out of date and needs to be altered. I've got it working by updating the intellijServer.js (until intellij fix it) with:
var cli = require('./intellijCli.js')
, Server = cli.requireKarmaModule('lib/server.js')
, cliOptions = { configFile: require.resolve('./intellij.conf.js') };
var browsers = cli.getBrowsers();
if (browsers != null) {
cliOptions.browsers = browsers;
}
var server=new Server(cliOptions);
server.start();
// Prevent karma server from being an orphan process.
// For example, if WebStorm is killed using SIGKILL, karma server will still be alive.
// When WebStorm is terminated, karma server's standard input is closed automatically.
process.stdin.resume();
process.stdin.on('close', function () {
// terminating orphan process
process.exit(123);
});
Once I got the server bit working i got another issue with No provider for “framework:jasmine”! (However this appears to be a separate unrelated issue affecting me, because I didn't fully setup karma).
This was resolved with:
npm install karma-jasmine --save-dev
npm install karma-chrome-launcher --save-dev
followed by
npm install