npm.io
0.0.1 • Published 10 years ago

mock-serialport

Licence
MIT
Version
0.0.1
Deps
0
Vulns
0
Weekly
0

I created this to mock out my serial port so I could test code depending on it while on a machine without a 'serial port'.

Install

npm install mock-serialport

Usage

This is how I use this in some of my non-serial ported tests. Like serialservo.

var fileExists = require('file-exists');
var SerialPort = require('serialport');
var serialPort;
if (fileExists(portName)) {
    serialPort = new SerialPort("/dev/ttyUSB0", {baudRate:9600});
} else {
    serialPort = new MockSerialPort();
}