
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Test command line on nodejs
$ npm install coffee -g
Coffee is useful to test command line in Mocha or other test frammework.
describe('cat', function() {
it('should concat input', function(done) {
var coffee = require('coffee');
coffee.spawn('cat')
.write('1')
.write('2')
.expect('stdout', '12')
.expect('code', 0)
.end(done);
})
})
You can also use fork for spawning Node processes.
coffee.fork('/path/to/file.js', ['args '])
.expect('stdout', '12\n')
.expect('stderr', '34\n')
.expect('code', 0)
.end(done);
In file.js
console.log(12);
console.log(34);
Run command using child_process.spawn
, then return Coffee
instance.
Arguments see child_process.spawn
Run command using child_process.fork
, then return Coffee
instance.
Arguments see child_process.fork
Assertion object
Assert type with expected value, expected value can be string, regular expression, and array.
coffee.spawn('echo', ['abcdefg'])
.expect('stdout', 'abcdefg')
.expect('stdout', /^abc/)
.expect('stdout', ['abcdefg', /abc/])
.end(done);
Accept type: stdout
, stderr
, code
, error
Write data to stdin, see example above.
Callback will be called after completing the assertion, the first argument is Error if throw exception.
Write data to process.stdout and process.stderr for debug
Copyright (c) 2015 popomore. Licensed under the MIT license.
FAQs
Test command line on Node.js.
The npm package coffee receives a total of 19,214 weekly downloads. As such, coffee popularity was classified as popular.
We found that coffee demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.