I am trying to autorun phpunit using gulp. When phpunit fails a test I see the following error in terminal (all passed tests do not cause the error):
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
events.js:188
throw err;
^
Error: Unhandled "error" event. (1)
at Domain.emit (events.js:186:19)
at Stream.emit (events.js:181:14)
at Stream.onerror (/var/www/html/wptest2/node_modules/readable-stream/lib/_stream_readable.js:640:52)
at emitOne (events.js:116:13)
at Stream.emit (events.js:211:7)
at next (/var/www/html/wptest2/node_modules/map-stream/index.js:74:19)
at /var/www/html/wptest2/node_modules/map-stream/index.js:84:7
at /var/www/html/wptest2/node_modules/gulp-phpunit/index.js:341:17
at /var/www/html/wptest2/node_modules/shelljs/src/exec.js:204:9
at ChildProcess.exithandler (child_process.js:282:5)
Gulpfile.js:
var gulp = require('gulp'),
connect = require('gulp-connect-php'),
gulpPhpunit = require('gulp-phpunit');
gulp.task('gulpPhpunit', function(done) {
var options = {debug: false};
gulp.src('phpunit.xml')
.pipe(gulpPhpunit('./vendor/bin/phpunit', options));
done();
});
gulp.task("default", gulp.series('gulpPhpunit'));
Does anyone know how to solve this?
Related
I installed goQuorum with quorum-wizard with 4 quorum nodes and 4 tessera nodes on IBFT. When I start the network with "./start.sh" I get
Starting Quorum network...
Waiting until all Tessera nodes are running...
Waiting until all Tessera nodes are running...
All Tessera nodes started
Starting Quorum nodes
Successfully started Quorum network.
--------------------------------------------------------------------------------
Tessera Node 1 public key:
BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=
Tessera Node 2 public key:
QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=
Tessera Node 3 public key:
1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg=
Tessera Node 4 public key:
oNspPPgszVUFw0qmGFfWwh1uxVUXgvBxleXORHj07g8=
--------------------------------------------------------------------------------
when I run "nmap -p 21000-21100" I get
21000/tcp open irtrans
21001/tcp open unknown
21002/tcp open unknown
21003/tcp open unknown
This is my truffle-config.js
const HDWalletProvider = require("#truffle/hdwallet-provider");
const mnemonic = "not my real mn mon ic num phrase dum get l gg";
module.exports = {
networks: {
rinkeby: {
provider: function() {
return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3/"+mnemonic);
},
network_id: '*',
timeoutBlocks: 100000,
networkCheckTimeout:2000000
},
quorum: {
provider: function() {
return new HDWalletProvider(mnemonic, "http://127.0.0.1:21000/", chainId=10);
},
network_id: '*',
type: 'quorum',
timeoutBlocks: 100000,
networkCheckTimeout:2000000
},
compilers: {
solc: {
version: "0.5.0",
settings: {
optimizer: {
enabled: true, // Default: false
runs: 1000 // Default: 200
},
evmVersion: "homestead" // Default: "byzantium"
}
}
}
};
When I cd in to the directory with the truffle-config.js and I run truffle deploy --reset --network quorum to compile my smart contracts I get the following error.
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
/root/dapp1/Dapp/node_modules/web3-core-helpers/src/errors.js:42
return new Error(message);
^
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/root/dapp1/Dapp/node_modules/web3-core-helpers/src/errors.js:42:16)
at XMLHttpRequest.request.onreadystatechange (/root/dapp1/Dapp/node_modules/web3-providers-http/src/index.js:92:32)
at XMLHttpRequestEventTarget.dispatchEvent (/root/dapp1/Dapp/node_modules/xhr2-cookies/xml-http-request-event-target.ts:44:13)
at XMLHttpRequest._setReadyState (/root/dapp1/Dapp/node_modules/xhr2-cookies/xml-http-request.ts:219:8)
at XMLHttpRequest._onHttpRequestError (/root/dapp1/Dapp/node_modules/xhr2-cookies/xml-http-request.ts:379:8)
at ClientRequest.<anonymous> (/root/dapp1/Dapp/node_modules/xhr2-cookies/xml-http-request.ts:266:37)
at ClientRequest.emit (events.js:315:20)
at Socket.socketOnEnd (_http_client.js:493:9)
at Socket.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
at PollingBlockTracker._performSync (/root/dapp1/Dapp/node_modules/eth-block-tracker/src/polling.js:51:24)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
I can deploy the smart contracts to rinkeby test net within this environment but I can't get smart contracts to deploy to quorum
I am using
Node v14.16.1
Ubuntu 18.04 (64 Bit)
Quorum 21.1.0
Web3.js v1.3.5
Truffle v5.3.4 (core: 5.3.4)
solidity v0.5.0
I've not used truffle with HDWalletProvider, which I believe is from an older version of Truffle. I'm not certain that will set up the node connection.
We would normally set up the configuration like the following in the quorum: {} section:
host: "localhost",
port: 22001,
type: "quorum"
I would suggest using that and see if it works.
Take a look at the truffle docs for working with quorum: https://www.trufflesuite.com/docs/truffle/distributed-ledger-support/working-with-quorum
Did you change from the default ports in the quorum-wizard?
The default for the node 1 RPC is 22000, the 21000 range is for p2p networking.
I would set the host and port per Satpal's answer above, as in the hdwallet documentation here.
var gm = require("gm").subClass({ imageMagick: true });
function conversion(image) {
const image = gm(image);
image.orientation(function(err, value) {
if (err) {
console.log("Error Occurred :",err);
}
}
While accessing image.orientation this is the error which occurs.
Error: write EPIPE
at afterWriteDispatched (internal/stream_base_commons.js:154:25)
at writeGeneric (internal/stream_base_commons.js:145:3)
at Socket._writeGeneric (net.js:786:11)
at Socket._write (net.js:798:8)
at doWrite (_stream_writable.js:403:12)
at writeOrBuffer (_stream_writable.js:387:5)
at Socket.Writable.write (_stream_writable.js:318:11)
at gm._spawn (/var/task/node_modules/gm/lib/command.js:253:18)
at gm._exec (/var/task/node_modules/gm/lib/command.js:190:17)
at gm.proto.<computed> [as orientation] (/var/task/node_modules/gm/lib/getters.js:68:12) {
errno: 'EPIPE',
code: 'EPIPE',
syscall: 'write'
}
These are some steps which i have already performed.
i have tried installing both imagemagick and graphicsmagick. https://www.npmjs.com/package/gm
Also there was suggestion to reinstall imagemagick and graphicsmagick and testing after restarting system. it also didn't worked
i am using Ubuntu , npm gm version:"^1.23.1", node version : nodejs12.x
In an attempt to install this plugin: (Github) Phone-call-trap-pluging, I do this on phonegap:
1- Install the plugin: phonegap plugin add https://github.com/renanoliveira/cordova-phone-call-trap
2- copy the the javascript file in the plugin and add it to my www/js folder, after adding logging messages to it, like this:
var PhoneCallTrap = {
onCall: function(successCallback, errorCallback) {
errorCallback = errorCallback || this.errorCallback;
cordova.exec(successCallback, errorCallback, 'com.sample.phonecalltrap', 'onCall', []);
},
errorCallback: function(err) {
console.log("WARNING: PhoneCallTrap errorCallback not implemented");
console.log(err);
}
};
module.exports = PhoneCallTrap;
3-
PhoneCallTrap.onCall(
function(state) {
console.log("CHANGE STATE: " + state);
switch (state) {
case "RINGING":
alert("Phone is ringing: ");
break;
case "OFFHOOK":
alert("Phone is off-hook");
break;
case "IDLE":
alert("Phone is idle");
break;
}
});
4- I get the above error in the question title
What am I doing wrong?
––––––––––––––––––––––––––––––––––––––––––––––
EDIT
Those errors show up when I do phonegap build
[phonegap] executing 'cordova build'...
cp: no such file or directory: /.../PHONEGAP/secondApp/icon.png
Running command: /.../PHONEGAP/secondApp/platforms/android/cordova/build
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
ERROR building one of the platforms: Error: ..../platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /..../platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (. ( (.../node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
––––––––––––––––––––––––––––––––––––––––––––
EDIT 2
I get "Class Not Found" error, when my code hits this line (console.log(err);) in the below code
var PhoneCallTrap = {
onCall: function(successCallback, errorCallback) {
errorCallback = errorCallback || this.errorCallback;
cordova.exec(successCallback, errorCallback, 'PhoneCallTrap', 'onCall', []);
},
errorCallback: function(err) {
console.log("WARNING: PhoneCallTrap errorCallback not implemented");
console.log(err);
console.log(err.stack);
}
};
module.exports = PhoneCallTrap;
Regarding the ANDROID_HOME environment variable, I use phonegap development client, which views my application by connecting to the server (which runs: phonegap serve)
I'm now using node.js(0.10.x) version, jest(0.4.x) version to test react.js.
Before I decided to test my react components, I have used node.js 0.12.x version. Change through nvm to 0.10.x.
I rebuilded the all the modules and restarted the test.
The error is below.
Using Jest CLI v0.4.17
PASS __tests__/unit/app.test.js (0.058s)
PASS __tests__/unit/preprocessor.js (0.68s)
FAIL __tests__/unit/mypage.test.js
Error: /Users/nuko/WebstormProjects/pliky/__tests__/unit/mypage.test.js: /Users/nuko/WebstormProjects/pliky/__tests__/unit/preprocessor.js: Parse Error: Line 1: Illegal import declaration
at throwError (/Users/nuko/WebstormProjects/pliky/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2813:21)
at throwErrorTolerant (/Users/nuko/WebstormProjects/pliky/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2825:24)
at parseSourceElement (/Users/nuko/WebstormProjects/pliky/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:6390:17)
at parseProgramElement (/Users/nuko/WebstormProjects/pliky/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:6446:16)
at parseProgramElements (/Users/nuko/WebstormProjects/pliky/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:6478:29)
at parseProgram (/Users/nuko/WebstormProjects/pliky/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:6491:16)
at Object.parse (/Users/nuko/WebstormProjects/pliky/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:7653:23)
at getAstForSource (/Users/nuko/WebstormProjects/pliky/node_modules/react-tools/node_modules/jstransform/src/jstransform.js:251:21)
at transform (/Users/nuko/WebstormProjects/pliky/node_modules/react-tools/node_modules/jstransform/src/jstransform.js:274:11)
at innerTransform (/Users/nuko/WebstormProjects/pliky/node_modules/react-tools/main.js:94:10)
at Object.module.exports.transform (/Users/nuko/WebstormProjects/pliky/node_modules/react-tools/main.js:20:18)
at Object.module.exports.process (/Users/nuko/WebstormProjects/pliky/__tests__/unit/preprocessor.js:5:27)
at Object.readAndPreprocessFileContent (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/src/lib/utils.js:432:33)
at Loader._execModule (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:209:11)
at Loader.requireModule (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:914:12)
at Loader.requireModuleOrMock (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:935:17)
at /Users/nuko/WebstormProjects/pliky/__tests__/unit/mypage.test.js:4:14
at Object.runContentWithLocalBindings (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/src/lib/utils.js:485:17)
at Loader._execModule (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:245:9)
at Loader.requireModule (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:914:12)
at jasmineTestRunner (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/src/jasmineTestRunner/jasmineTestRunner.js:292:16)
at /Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/src/TestRunner.js:376:12
at tryCatcher (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/node_modules/bluebird/js/main/promise.js:503:31)
at Promise._settlePromiseAt (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/node_modules/bluebird/js/main/promise.js:577:18)
at Promise._settlePromises (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/node_modules/bluebird/js/main/promise.js:693:14)
at Async._drainQueue (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/node_modules/bluebird/js/main/async.js:133:10)
at Async.drainQueues (/Users/nuko/WebstormProjects/pliky/node_modules/jest-cli/node_modules/bluebird/js/main/async.js:15:14)
at process._tickCallback (node.js:448:13)
1 test failed, 2 tests passed (3 total)
Run time: 2.189s
npm ERR! Test failed. See above for more details.
npm ERR! not ok code 0
My preprocessor.js code.(same as the official document script)
var ReactTools = require('react-tools');
module.exports = {
process: function(src) {
return ReactTools.transform(src);
}
};
My mypage.test.js code.
jest.dontMock('../../React/mypage.js');
var React = require('react/addons'),
Mypage = require('../../React/mypage.js'),
TestUtils = React.addons.TestUtils;
describe('mypage', function() {
var MypageElement = TestUtils.renderIntoDocument(<Mypage />);
var list = TestUtils.scryRenderedDOMComponentsWithTag(MypageElement, 'option');
it('has 3 default items', function() {
expect(list.props.children.length).toEqual(5);
});
});
And I added this part to package.json file.
"jest": {
"scriptPreprocessor": "./__tests__/unit/preprocessor.js",
"unmockedModulePathPatterns": [
"./node_modules/react"
]
},
Where is this error come from and how can I fix this? Please let me know. Thank you.
Presumably your mypage.js component has as its first line something like
import React from 'react' or something similar. That is ES6 syntax and by default ReactTools is only compatible with ES5 code, the equivalent being var React = require('react').
To fix this enable harmony mode during your transform.
var ReactTools = require('react-tools');
module.exports = {
process: function(src) {
return ReactTools.transform(src, { harmony: true });
}
};
JSTransform documentation here
I am developing a CLI tool running on node.js. I am trying to setup my environment for tdd but I have difficulties to do it with gulp.
All my 'standalone' tasks from gulp work.
Here they are:
Build task:
var tsProject = ts.createProject({
declarationFiles: true,
noEmitOnError: true,
module: 'commonjs',
target: 'es5',
sortOutput: true,
typescript: require('typescript') //usefull during typescript 1.5 alpha
});
gulp.task('build', function() {
var tsResult = gulp.src([
PATHS.lib + '/**/*.ts'
])
.pipe(sourcemaps.init())
.pipe(ts(tsProject));
return merge([ // Merge the two output streams, so this task is finished when the IO of both operations are done.
tsResult.dts.pipe(gulp.dest(PATHS.build + '/definitions')),
tsResult.js
.pipe(sourcemaps.write())
.pipe(gulp.dest(PATHS.build + '/js'))
]);
});
Test task:
gulp.task('test', ['build'], function () {
return gulp.src(PATHS.test + '/**/*.js', {read: false})
.pipe(mocha({
reporter: 'spec',
globals: {
should: require('should'),
sinon: require('sinon'),
mockery: require('mockery')
}
}))
.on('error', gutil.log);
});
As you can see I have one task which build my typescript files into es5 compatible js. And another task that run my tests with the precedent build.
If I run them alone. It works.
I have tried to add a watch mode:
build:watch:
gulp.task('build:watch', ['build'], function() {
gulp.watch([
PATHS.lib + '/**/*.ts'
], ['build']);
});
test:watch:
gulp.task('test:watch', ['test'], function () {
gulp.watch([
PATHS.lib + '/**/*.ts',
PATHS.test + '/**/*.js'
], ['test']);
});
build:watch works. Every time I edit a typescript file, the build task is triggered and rebuild my project. (It's not really relevant here because the test task trigger build. It's just to say that this watch mode works)
test:watch doesn't work. The first iteration (triggered by the task dependencie) work, but when I edit a typescript file or a test file, I got this error:
{ [TypeError: Cannot read property 'defaultEncoding' of undefined]
domain:
{ domain: null,
_events: { error: [Function: handleException] },
_maxListeners: undefined,
members: [] },
domainThrown: true,
name: 'TypeError',
message: 'Cannot read property \'defaultEncoding\' of undefined',
stack: 'TypeError: Cannot read property \'defaultEncoding\' of undefined\n at DestroyableTransform.Writable.write (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:186:21)\n at Glob.<anonymous> (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/index.js:44:14)\n at Glob.emit (events.js:107:17)\n at Glob._emitMatch (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/glob.js:457:8)\n at Glob._processReaddir2 (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/glob.js:405:12)\n at /Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/glob.js:345:17\n at RES (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/node_modules/inflight/inflight.js:23:14)\n at /Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/node_modules/inflight/inflight.js:30:13\n at process._tickDomainCallback (node.js:381:11)',
showStack: true,
showProperties: true,
plugin: 'gulp-mocha' }
And if you want, here the gulp stack :
[10:58:24] Using gulpfile ~/Documents/Work/jsProjects/hawker/gulpfile.js
[10:58:24] Starting 'build'...
[10:58:25] Finished 'build' after 1.01 s
[10:58:25] Starting 'test'...
Hawker
✓ should get the Logger
✓ should get the Parser
✓ should define a file loader
✓ should define a url loader
✓ should launch hawker
FileLoader
✓ should be defined
✓ should get a configuration file
Parser
✓ should be defined
✓ should parse configuration file
9 passing (24ms)
[10:58:26] Finished 'test' after 98 ms
[10:58:26] Starting 'test:watch'...
[10:58:26] Finished 'test:watch' after 14 ms
[10:58:28] Starting 'build'...
[10:58:28] { [TypeError: Cannot read property 'defaultEncoding' of undefined] ...
Do you have any suggestion?
All right, I find the problem.
I use mockery in my unit tests and I forget to disable it after some tests. I just add in my test files :
afterEach(function() {
mockery.disable();
});
Have a good day.
Thomas