diff --git a/.eslintrc b/.eslintrc index e87c04b91..3e0b2c6bf 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,10 +1,12 @@ { "extends": [ - "plugin:node/recommended" + "plugin:node/recommended", + "plugin:mocha/recommended" ], "plugins": [ "prettier", - "node" + "node", + "mocha" ], "env": { "node": true, @@ -62,6 +64,9 @@ ], "valid-jsdoc": [ 0 - ] + ], + "mocha/no-mocha-arrows": [0], + "mocha/no-setup-in-describe": [0], + "mocha/no-hooks-for-single-case": [0] } } diff --git a/package.json b/package.json index b34bcf7a1..f99c0d2e1 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "eslint": "^6.1.0", "eslint-config-prettier": "^6.0.0", "eslint-plugin-import": "^2.16.0", + "eslint-plugin-mocha": "^6.1.0", "eslint-plugin-node": "^9.0.1", "eslint-plugin-prettier": "^3.0.1", "eslint-plugin-promise": "^4.0.1", diff --git a/packages/binding-mock/binding-mock.test.js b/packages/binding-mock/binding-mock.test.js index 0e839f31d..f0cb72b6b 100644 --- a/packages/binding-mock/binding-mock.test.js +++ b/packages/binding-mock/binding-mock.test.js @@ -16,7 +16,6 @@ describe('BindingMock', () => { it('constructs', () => { new BindingMock({}) }) - it('needs more testing') describe('instance method', () => { beforeEach(function() { diff --git a/packages/bindings/lib/bindings.test.js b/packages/bindings/lib/bindings.test.js index 34c4b7002..ddd4d3b23 100644 --- a/packages/bindings/lib/bindings.test.js +++ b/packages/bindings/lib/bindings.test.js @@ -1,3 +1,4 @@ +/* eslint-disable mocha/no-pending-tests */ let platform switch (process.platform) { case 'win32': @@ -323,7 +324,7 @@ function testBinding(bindingName, Binding, testPort) { }) }) - describe.only('#write', () => { + describe('#write', () => { it('errors asynchronously when not open', done => { const binding = new Binding({ disconnect, diff --git a/packages/parser-inter-byte-timeout/inter-byte-timeout.test.js b/packages/parser-inter-byte-timeout/inter-byte-timeout.test.js index a0be38fc8..8b216eab6 100644 --- a/packages/parser-inter-byte-timeout/inter-byte-timeout.test.js +++ b/packages/parser-inter-byte-timeout/inter-byte-timeout.test.js @@ -71,7 +71,7 @@ describe('InterByteTimeoutParser', () => { parser.end() assert(spy.calledOnce, 'expecting 1 data event') }) - it('emits all buffered data when stream ends', () => { + it('handles not having any buffered data when stream ends', () => { const spy = sinon.spy() const parser = new InterByteTimeoutParser({ interval: 15 }) parser.on('data', spy) diff --git a/packages/parser-readline/readline.test.js b/packages/parser-readline/readline.test.js index c2a42bee1..a877dca63 100644 --- a/packages/parser-readline/readline.test.js +++ b/packages/parser-readline/readline.test.js @@ -90,18 +90,6 @@ describe('ReadlineParser', () => { }) }) - it('allows setting of the delimiter with a string', () => { - new ReadlineParser({ delimiter: 'string' }) - }) - - it('allows setting of the delimiter with a buffer', () => { - new ReadlineParser({ delimiter: Buffer.from([1]) }) - }) - - it('allows setting of the delimiter with an array of bytes', () => { - new ReadlineParser({ delimiter: [1] }) - }) - it("doesn't emits empty data events", () => { const spy = sinon.spy() const parser = new ReadlineParser({ delimiter: 'a' }) diff --git a/packages/serialport/test-arduino/stress.js b/packages/serialport/test-arduino/stress.js index fcae7fc0f..000aa4ce6 100644 --- a/packages/serialport/test-arduino/stress.js +++ b/packages/serialport/test-arduino/stress.js @@ -21,16 +21,12 @@ describe('the stress', () => { const testPort = process.env.TEST_PORT if (!testPort) { + // eslint-disable-next-line mocha/no-pending-tests it('cannot be tested as we have no test ports') return } describe('of 2 minutes of running 1k writes', () => { - if (process.version.match('v0.10.')) { - it('either leaks like a siv or memwatch is broken on v10') - return - } - it("doesn't leak memory", done => { const data = Buffer.alloc(1024) const hd = new memwatch.HeapDiff() diff --git a/packages/stream/stream.test.js b/packages/stream/stream.test.js index d77d08669..d450b7d8b 100644 --- a/packages/stream/stream.test.js +++ b/packages/stream/stream.test.js @@ -164,7 +164,7 @@ describe('SerialPort', () => { }) it('allows optional options', function(done) { - this.port = new SerialPort('/dev/exists', done) + this.port = new SerialPort('/dev/exists', () => done()) }) })