From 7f96704473953150fb330761a792856be8c471aa Mon Sep 17 00:00:00 2001 From: ta2edchimp Date: Thu, 17 Mar 2016 10:19:46 +0100 Subject: [PATCH] fix(tests): Use proxyquire to mock fs object instead of mocking the filesystem. --- package.json | 2 +- test/index.js | 20 +++++--------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 5266666..d42e7b0 100644 --- a/package.json +++ b/package.json @@ -37,9 +37,9 @@ "eslint": "2.4.0", "eslint-config-kentcdodds": "6.0.0", "ghooks": "1.0.3", - "mock-fs": "3.8.0", "npm-run-all": "1.5.3", "nyc": "6.1.1", + "proxyquire": "1.7.4", "semantic-release": "4.3.5", "validate-commit-msg": "2.4.0" }, diff --git a/test/index.js b/test/index.js index a5eb92a..ea17995 100644 --- a/test/index.js +++ b/test/index.js @@ -1,19 +1,10 @@ -import mock from 'mock-fs' +import proxyquire from 'proxyquire' import test from 'ava' -import findNewRules from './index' -test.before(() => { - mock({ - './node_modules/eslint/lib/rules': { - 'foo-rule.js': '', - 'bar-rule.js': '', - 'baz-thing.js': '', - }, - }) -}) - -test.after(() => { - mock.restore() +const findNewRules = proxyquire('../index', { + fs: { + readdirSync: () => ['foo-rule.js', 'bar-rule.js', 'baz-thing.js'], + }, }) test('returns the difference between what it finds in eslint/lib/rules and the rules array it is passed', t => { @@ -26,4 +17,3 @@ test('returns an empty array if there is no difference', t => { t.true(Array.isArray(missingRules)) t.same(missingRules.length, 0) }) -