From e26bd05edef35238214676b3e7d2d2d8ec8a65e1 Mon Sep 17 00:00:00 2001 From: Juan Soto Date: Fri, 26 Feb 2016 12:14:09 +0000 Subject: [PATCH] Close #536 PR: Move files argument to api.run(). Fixes #534 --- api.js | 18 +---- cli.js | 18 +++-- lib/watcher.js | 16 ++--- test/api.js | 176 ++++++++++++++++++++++-------------------------- test/watcher.js | 49 +++++++------- 5 files changed, 130 insertions(+), 147 deletions(-) diff --git a/api.js b/api.js index b08f9ef..944e3e0 100644 --- a/api.js +++ b/api.js @@ -18,7 +18,7 @@ var fork = require('./lib/fork'); var formatter = require('./lib/enhance-assert').formatter(); var CachingPrecompiler = require('./lib/caching-precompiler'); -function Api(files, options) { +function Api(options) { if (!(this instanceof Api)) { throw new TypeError('Class constructor Api cannot be invoked without \'new\''); } @@ -28,16 +28,6 @@ function Api(files, options) { this.options = options || {}; this.options.require = (this.options.require || []).map(resolveCwd); - if (!files || files.length === 0) { - this.files = [ - 'test.js', - 'test-*.js', - 'test' - ]; - } else { - this.files = files; - } - this.excludePatterns = [ '!**/node_modules/**', '!**/fixtures/**', @@ -66,7 +56,6 @@ Api.prototype._reset = function () { this.stats = []; this.tests = []; this.base = ''; - this.explicitTitles = false; }; Api.prototype._runFile = function (file) { @@ -136,7 +125,7 @@ Api.prototype._handleTest = function (test) { }; Api.prototype._prefixTitle = function (file) { - if (this.fileCount === 1 && !this.explicitTitles) { + if (this.fileCount === 1 && !this.options.explicitTitles) { return ''; } @@ -162,8 +151,7 @@ Api.prototype.run = function (files) { var self = this; this._reset(); - this.explicitTitles = Boolean(files); - return handlePaths(files || this.files, this.excludePatterns) + return handlePaths(files, this.excludePatterns) .map(function (file) { return path.resolve(file); }) diff --git a/cli.js b/cli.js index 36d3832..7164983 100755 --- a/cli.js +++ b/cli.js @@ -93,11 +93,12 @@ if (cli.flags.init) { return; } -var api = new Api(cli.input.length ? cli.input : arrify(conf.files), { +var api = new Api({ failFast: cli.flags.failFast, serial: cli.flags.serial, require: arrify(cli.flags.require), - cacheEnabled: cli.flags.cache !== false + cacheEnabled: cli.flags.cache !== false, + explicitTitles: cli.flags.watch }); var reporter; @@ -121,9 +122,18 @@ api.on('error', logger.unhandledError); api.on('stdout', logger.stdout); api.on('stderr', logger.stderr); +var files = cli.input.length ? cli.input : arrify(conf.files); +if (files.length === 0) { + files = [ + 'test.js', + 'test-*.js', + 'test' + ]; +} + if (cli.flags.watch) { try { - watcher.start(logger, api, arrify(cli.flags.source), process.stdin); + watcher.start(logger, api, files, arrify(cli.flags.source), process.stdin); } catch (err) { if (err.name === 'AvaError') { // An AvaError may be thrown if chokidar is not installed. Log it nicely. @@ -135,7 +145,7 @@ if (cli.flags.watch) { } } } else { - api.run() + api.run(files) .then(function () { logger.finish(); logger.exit(api.failCount > 0 || api.rejectionCount > 0 || api.exceptionCount > 0 ? 1 : 0); diff --git a/lib/watcher.js b/lib/watcher.js index 2805d73..0646484 100644 --- a/lib/watcher.js +++ b/lib/watcher.js @@ -47,16 +47,16 @@ function getChokidarPatterns(sources, initialFiles) { return {paths: paths, ignored: ignored}; } -exports.start = function (logger, api, sources, stdin) { - var isTest = makeTestMatcher(api.files, api.excludePatterns); +exports.start = function (logger, api, files, sources, stdin) { + var isTest = makeTestMatcher(files, api.excludePatterns); + var patterns = getChokidarPatterns(sources, files); - var patterns = getChokidarPatterns(sources, api.files); var watcher = requireChokidar().watch(patterns.paths, { ignored: patterns.ignored, ignoreInitial: true }); - var busy = api.run().then(function () { + var busy = api.run(files).then(function () { logger.finish(); }).catch(rethrowAsync); @@ -90,7 +90,7 @@ exports.start = function (logger, api, sources, stdin) { debounceAgain = false; debounce(); } else { - busy = runAfterChanges(logger, api, isTest, dirtyStates); + busy = runAfterChanges(logger, api, files, isTest, dirtyStates); dirtyStates = {}; debouncing = null; debounceAgain = false; @@ -122,7 +122,7 @@ exports.start = function (logger, api, sources, stdin) { // Cancel the debouncer again, it might have restarted while waiting for // the busy promise to fulfil. cancelDebounce(); - busy = runAfterChanges(logger, api, isTest, {}); + busy = runAfterChanges(logger, api, files, isTest, {}); }); }); }; @@ -172,7 +172,7 @@ function makeTestMatcher(files, excludePatterns) { }; } -function runAfterChanges(logger, api, isTest, dirtyStates) { +function runAfterChanges(logger, api, files, isTest, dirtyStates) { var dirtyPaths = Object.keys(dirtyStates); var dirtyTests = dirtyPaths.filter(isTest); var addedOrChangedTests = dirtyTests.filter(function (path) { @@ -195,7 +195,7 @@ function runAfterChanges(logger, api, isTest, dirtyStates) { if (dirtyPaths.length > 0 && dirtyTests.length === dirtyPaths.length) { resolve(api.run(addedOrChangedTests)); } else { - resolve(api.run()); + resolve(api.run(files)); } }).then(function () { logger.finish(); diff --git a/test/api.js b/test/api.js index 918cdb1..453f141 100644 --- a/test/api.js +++ b/test/api.js @@ -17,9 +17,9 @@ test('must be called with new', function (t) { test('ES2015 support', function (t) { t.plan(1); - var api = new Api([path.join(__dirname, 'fixture/es2015.js')]); + var api = new Api(); - api.run() + api.run([path.join(__dirname, 'fixture/es2015.js')]) .then(function () { t.is(api.passCount, 1); }); @@ -28,9 +28,9 @@ test('ES2015 support', function (t) { test('generators support', function (t) { t.plan(1); - var api = new Api([path.join(__dirname, 'fixture/generators.js')]); + var api = new Api(); - api.run() + api.run([path.join(__dirname, 'fixture/generators.js')]) .then(function () { t.is(api.passCount, 1); }); @@ -39,9 +39,9 @@ test('generators support', function (t) { test('async/await support', function (t) { t.plan(1); - var api = new Api([path.join(__dirname, 'fixture/async-await.js')]); + var api = new Api(); - api.run() + api.run([path.join(__dirname, 'fixture/async-await.js')]) .then(function () { t.is(api.passCount, 2); }); @@ -66,9 +66,9 @@ test('test title prefixes — multiple files', function (t) { ]; var index; - var api = new Api(files); + var api = new Api(); - api.run() + api.run(files) .then(function () { // if all lines were removed from expected output // actual output matches expected output @@ -97,9 +97,9 @@ test('test title prefixes — single file', function (t) { ]; var index; - var api = new Api(files); + var api = new Api(); - api.run() + api.run(files) .then(function () { // if all lines were removed from expected output // actual output matches expected output @@ -128,7 +128,9 @@ test('test title prefixes — single file (explicit)', function (t) { ]; var index; - var api = new Api(); + var api = new Api({ + explicitTitles: true + }); api.run(files) .then(function () { @@ -155,9 +157,9 @@ test('display filename prefixes for failed test stack traces', function (t) { path.join(__dirname, 'fixture/one-pass-one-fail.js') ]; - var api = new Api(files); + var api = new Api(); - api.run() + api.run(files) .then(function () { t.is(api.passCount, 2); t.is(api.failCount, 1); @@ -175,9 +177,9 @@ test('display filename prefixes for failed test stack traces in subdirs', functi path.join(__dirname, 'fixture/subdir/failing-subdir.js') ]; - var api = new Api(files); + var api = new Api(); - api.run() + api.run(files) .then(function () { t.is(api.passCount, 1); t.is(api.failCount, 1); @@ -188,7 +190,7 @@ test('display filename prefixes for failed test stack traces in subdirs', functi test('fail-fast mode', function (t) { t.plan(5); - var api = new Api([path.join(__dirname, 'fixture/fail-fast.js')], { + var api = new Api({ failFast: true }); @@ -201,7 +203,7 @@ test('fail-fast mode', function (t) { }); }); - api.run() + api.run([path.join(__dirname, 'fixture/fail-fast.js')]) .then(function () { t.ok(api.options.failFast); t.same(tests, [{ @@ -220,11 +222,11 @@ test('fail-fast mode', function (t) { test('serial execution mode', function (t) { t.plan(3); - var api = new Api([path.join(__dirname, 'fixture/serial.js')], { + var api = new Api({ serial: true }); - api.run() + api.run([path.join(__dirname, 'fixture/serial.js')]) .then(function () { t.ok(api.options.serial); t.is(api.passCount, 3); @@ -235,9 +237,9 @@ test('serial execution mode', function (t) { test('circular references on assertions do not break process.send', function (t) { t.plan(2); - var api = new Api([path.join(__dirname, 'fixture/circular-reference-on-assertion.js')]); + var api = new Api(); - api.run() + api.run([path.join(__dirname, 'fixture/circular-reference-on-assertion.js')]) .then(function () { t.is(api.failCount, 1); t.match(api.errors[0].error.message, /'c'.*?'d'/); @@ -247,9 +249,9 @@ test('circular references on assertions do not break process.send', function (t) test('change process.cwd() to a test\'s directory', function (t) { t.plan(1); - var api = new Api([path.join(__dirname, 'fixture/process-cwd.js')]); + var api = new Api(); - api.run() + api.run([path.join(__dirname, 'fixture/process-cwd.js')]) .then(function () { t.is(api.passCount, 1); }); @@ -258,14 +260,14 @@ test('change process.cwd() to a test\'s directory', function (t) { test('unhandled promises will throw an error', function (t) { t.plan(3); - var api = new Api([path.join(__dirname, 'fixture/loud-rejection.js')]); + var api = new Api(); api.on('error', function (data) { t.is(data.name, 'Error'); t.match(data.message, /You can\'t handle this!/); }); - api.run() + api.run([path.join(__dirname, 'fixture/loud-rejection.js')]) .then(function () { t.is(api.passCount, 1); }); @@ -274,14 +276,14 @@ test('unhandled promises will throw an error', function (t) { test('uncaught exception will throw an error', function (t) { t.plan(3); - var api = new Api([path.join(__dirname, 'fixture/uncaught-exception.js')]); + var api = new Api(); api.on('error', function (data) { t.is(data.name, 'Error'); t.match(data.message, /Can\'t catch me!/); }); - api.run() + api.run([path.join(__dirname, 'fixture/uncaught-exception.js')]) .then(function () { t.is(api.passCount, 1); }); @@ -290,8 +292,9 @@ test('uncaught exception will throw an error', function (t) { test('errors can occur without messages', function (t) { t.plan(2); - var api = new Api([path.join(__dirname, 'fixture/error-without-message.js')]); - api.run() + var api = new Api(); + + api.run([path.join(__dirname, 'fixture/error-without-message.js')]) .then(function () { t.is(api.failCount, 1); t.is(api.errors.length, 1); @@ -301,7 +304,9 @@ test('errors can occur without messages', function (t) { test('stack traces for exceptions are corrected using a source map file', function (t) { t.plan(4); - var api = new Api([path.join(__dirname, 'fixture/source-map-file.js')], {cacheEnabled: true}); + var api = new Api({ + cacheEnabled: true + }); api.on('error', function (data) { t.match(data.message, /Thrown by source-map-fixtures/); @@ -309,7 +314,7 @@ test('stack traces for exceptions are corrected using a source map file', functi t.match(data.stack, /^.*?Immediate\b.*source-map-file.js:11.*$/m); }); - api.run() + api.run([path.join(__dirname, 'fixture/source-map-file.js')]) .then(function () { t.is(api.passCount, 1); }); @@ -318,7 +323,9 @@ test('stack traces for exceptions are corrected using a source map file', functi test('stack traces for exceptions are corrected using a source map file (cache off)', function (t) { t.plan(4); - var api = new Api([path.join(__dirname, 'fixture/source-map-file.js')], {cacheEnabled: false}); + var api = new Api({ + cacheEnabled: false + }); api.on('error', function (data) { t.match(data.message, /Thrown by source-map-fixtures/); @@ -326,7 +333,7 @@ test('stack traces for exceptions are corrected using a source map file (cache o t.match(data.stack, /^.*?Immediate\b.*source-map-file.js:11.*$/m); }); - api.run() + api.run([path.join(__dirname, 'fixture/source-map-file.js')]) .then(function () { t.is(api.passCount, 1); }); @@ -335,7 +342,9 @@ test('stack traces for exceptions are corrected using a source map file (cache o test('stack traces for exceptions are corrected using a source map, taking an initial source map for the test file into account (cache on)', function (t) { t.plan(4); - var api = new Api([path.join(__dirname, 'fixture/source-map-initial.js')], {cacheEnabled: true}); + var api = new Api({ + cacheEnabled: true + }); api.on('error', function (data) { t.match(data.message, /Thrown by source-map-fixtures/); @@ -343,7 +352,7 @@ test('stack traces for exceptions are corrected using a source map, taking an in t.match(data.stack, /^.*?Immediate\b.*source-map-initial-input.js:7.*$/m); }); - api.run() + api.run([path.join(__dirname, 'fixture/source-map-initial.js')]) .then(function () { t.is(api.passCount, 1); }); @@ -352,7 +361,9 @@ test('stack traces for exceptions are corrected using a source map, taking an in test('stack traces for exceptions are corrected using a source map, taking an initial source map for the test file into account (cache off)', function (t) { t.plan(4); - var api = new Api([path.join(__dirname, 'fixture/source-map-initial.js')], {cacheEnabled: false}); + var api = new Api({ + cacheEnabled: false + }); api.on('error', function (data) { t.match(data.message, /Thrown by source-map-fixtures/); @@ -360,7 +371,7 @@ test('stack traces for exceptions are corrected using a source map, taking an in t.match(data.stack, /^.*?Immediate\b.*source-map-initial-input.js:7.*$/m); }); - api.run() + api.run([path.join(__dirname, 'fixture/source-map-initial.js')]) .then(function () { t.is(api.passCount, 1); }); @@ -369,9 +380,9 @@ test('stack traces for exceptions are corrected using a source map, taking an in test('absolute paths', function (t) { t.plan(1); - var api = new Api([path.resolve('test/fixture/es2015.js')]); + var api = new Api(); - api.run() + api.run([path.resolve('test/fixture/es2015.js')]) .then(function () { t.is(api.passCount, 1); }); @@ -380,9 +391,9 @@ test('absolute paths', function (t) { test('search directories recursively for files', function (t) { t.plan(2); - var api = new Api([path.join(__dirname, 'fixture/subdir')]); + var api = new Api(); - api.run() + api.run([path.join(__dirname, 'fixture/subdir')]) .then(function () { t.is(api.passCount, 2); t.is(api.failCount, 1); @@ -392,9 +403,9 @@ test('search directories recursively for files', function (t) { test('titles of both passing and failing tests and AssertionErrors are returned', function (t) { t.plan(3); - var api = new Api([path.join(__dirname, 'fixture/one-pass-one-fail.js')]); + var api = new Api(); - api.run() + api.run([path.join(__dirname, 'fixture/one-pass-one-fail.js')]) .then(function () { t.match(api.errors[0].title, /this is a failing test/); t.match(api.tests[0].title, /this is a passing test/); @@ -405,69 +416,69 @@ test('titles of both passing and failing tests and AssertionErrors are returned' test('empty test files cause an AvaError to be emitted', function (t) { t.plan(2); - var api = new Api([path.join(__dirname, 'fixture/empty.js')]); + var api = new Api(); api.on('error', function (err) { t.is(err.name, 'AvaError'); t.match(err.message, /No tests found.*?import "ava"/); }); - return api.run(); + return api.run([path.join(__dirname, 'fixture/empty.js')]); }); test('test file with no tests causes an AvaError to be emitted', function (t) { t.plan(2); - var api = new Api([path.join(__dirname, 'fixture/no-tests.js')]); + var api = new Api(); api.on('error', function (err) { t.is(err.name, 'AvaError'); t.match(err.message, /No tests/); }); - return api.run(); + return api.run([path.join(__dirname, 'fixture/no-tests.js')]); }); test('test file that immediately exits with 0 exit code ', function (t) { t.plan(2); - var api = new Api([path.join(__dirname, 'fixture/immediate-0-exit.js')]); + var api = new Api(); api.on('error', function (err) { t.is(err.name, 'AvaError'); t.match(err.message, /Test results were not received from/); }); - return api.run(); + return api.run([path.join(__dirname, 'fixture/immediate-0-exit.js')]); }); test('testing nonexistent files causes an AvaError to be emitted', function (t) { t.plan(2); - var api = new Api([path.join(__dirname, 'fixture/broken.js')]); + var api = new Api(); api.on('error', function (err) { t.is(err.name, 'AvaError'); t.match(err.message, /Couldn't find any files to test/); }); - return api.run(); + return api.run([path.join(__dirname, 'fixture/broken.js')]); }); test('test file in node_modules is ignored', function (t) { t.plan(2); - var api = new Api([path.join(__dirname, 'fixture/ignored-dirs/node_modules/test.js')]); + var api = new Api(); api.on('error', function (err) { t.is(err.name, 'AvaError'); t.match(err.message, /Couldn't find any files to test/); }); - return api.run(); + return api.run([path.join(__dirname, 'fixture/ignored-dirs/node_modules/test.js')]); }); -test('test file in node_modules is ignored (explicit)', function (t) { +test('test file in node_modules is ignored', function (t) { t.plan(2); var api = new Api(); @@ -483,19 +494,6 @@ test('test file in node_modules is ignored (explicit)', function (t) { test('test file in fixtures is ignored', function (t) { t.plan(2); - var api = new Api([path.join(__dirname, 'fixture/ignored-dirs/fixtures/test.js')]); - - api.on('error', function (err) { - t.is(err.name, 'AvaError'); - t.match(err.message, /Couldn't find any files to test/); - }); - - return api.run(); -}); - -test('test file in fixtures is ignored (explicit)', function (t) { - t.plan(2); - var api = new Api(); api.on('error', function (err) { @@ -509,19 +507,6 @@ test('test file in fixtures is ignored (explicit)', function (t) { test('test file in helpers is ignored', function (t) { t.plan(2); - var api = new Api([path.join(__dirname, 'fixture/ignored-dirs/helpers/test.js')]); - - api.on('error', function (err) { - t.is(err.name, 'AvaError'); - t.match(err.message, /Couldn't find any files to test/); - }); - - return api.run(); -}); - -test('test file in helpers is ignored (explicit)', function (t) { - t.plan(2); - var api = new Api(); api.on('error', function (err) { @@ -537,12 +522,11 @@ test('Node.js-style --require CLI argument', function (t) { var requirePath = './' + path.relative('.', path.join(__dirname, 'fixture/install-global.js')).replace(/\\/g, '/'); - var api = new Api( - [path.join(__dirname, 'fixture/validate-installed-global.js')], - {require: [requirePath]} - ); + var api = new Api({ + require: [requirePath] + }); - api.run() + api.run([path.join(__dirname, 'fixture/validate-installed-global.js')]) .then(function () { t.is(api.passCount, 1); }); @@ -551,9 +535,9 @@ test('Node.js-style --require CLI argument', function (t) { test('power-assert support', function (t) { t.plan(3); - var api = new Api([path.join(__dirname, 'fixture/power-assert.js')]); + var api = new Api(); - api.run() + api.run([path.join(__dirname, 'fixture/power-assert.js')]) .then(function () { t.ok(api.errors[0].error.powerAssertContext); @@ -572,9 +556,9 @@ test('power-assert support', function (t) { test('caching is enabled by default', function (t) { t.plan(3); rimraf.sync(path.join(__dirname, 'fixture/caching/node_modules')); - var api = new Api([path.join(__dirname, 'fixture/caching/test.js')]); + var api = new Api(); - api.run() + api.run([path.join(__dirname, 'fixture/caching/test.js')]) .then(function () { var files = fs.readdirSync(path.join(__dirname, 'fixture/caching/node_modules/.cache/ava')); t.is(files.length, 2); @@ -595,9 +579,9 @@ test('caching is enabled by default', function (t) { test('caching can be disabled', function (t) { t.plan(1); rimraf.sync(path.join(__dirname, 'fixture/caching/node_modules')); - var api = new Api([path.join(__dirname, 'fixture/caching/test.js')], {cacheEnabled: false}); + var api = new Api({cacheEnabled: false}); - api.run() + api.run([path.join(__dirname, 'fixture/caching/test.js')]) .then(function () { t.false(fs.existsSync(path.join(__dirname, 'fixture/caching/node_modules/.cache/ava'))); t.end(); @@ -607,9 +591,9 @@ test('caching can be disabled', function (t) { test('test file with only skipped tests does not create a failure', function (t) { t.plan(2); - var api = new Api([path.join(__dirname, 'fixture/skip-only.js')]); + var api = new Api(); - api.run() + api.run([path.join(__dirname, 'fixture/skip-only.js')]) .then(function () { t.is(api.tests.length, 1); t.true(api.tests[0].skip); @@ -619,11 +603,11 @@ test('test file with only skipped tests does not create a failure', function (t) test('resets state before running', function (t) { t.plan(2); - var api = new Api([path.resolve('test/fixture/es2015.js')]); + var api = new Api(); - api.run().then(function () { + api.run([path.resolve('test/fixture/es2015.js')]).then(function () { t.is(api.passCount, 1); - return api.run(); + return api.run([path.resolve('test/fixture/es2015.js')]); }).then(function () { t.is(api.passCount, 1); }); diff --git a/test/watcher.js b/test/watcher.js index 29d5880..a14c961 100644 --- a/test/watcher.js +++ b/test/watcher.js @@ -20,7 +20,7 @@ test('chokidar is not installed', function (t) { }); try { - subject.start({}, {files: [], excludePatterns: []}, []); + subject.start({}, {excludePatterns: []}, [], []); } catch (err) { t.is(err.name, 'AvaError'); t.is(err.message, 'The optional dependency chokidar failed to install and is required for --watch. Chokidar is likely not supported on your platform.'); @@ -40,7 +40,12 @@ test('chokidar is installed', function (_t) { }; var api = { - run: sinon.stub() + run: sinon.stub(), + excludePatterns: [ + '!**/node_modules/**', + '!**/fixtures/**', + '!**/helpers/**' + ] }; var subject = proxyquire.noCallThru().load('../lib/watcher', { @@ -57,6 +62,7 @@ test('chokidar is installed', function (_t) { var clock; var emitter; var stdin; + var files; _t.beforeEach(function (done) { if (clock) { clock.uninstall(); @@ -74,16 +80,11 @@ test('chokidar is installed', function (_t) { api.run.reset(); api.run.returns(new Promise(function () {})); - api.files = [ + files = [ 'test.js', 'test-*.js', 'test' ]; - api.excludePatterns = [ - '!**/node_modules/**', - '!**/fixtures/**', - '!**/helpers/**' - ]; stdin = new PassThrough(); stdin.pause(); @@ -92,7 +93,7 @@ test('chokidar is installed', function (_t) { }); var start = function (sources) { - subject.start(logger, api, sources || [], stdin); + subject.start(logger, api, files, sources || [], stdin); }; var add = function (path) { @@ -134,7 +135,7 @@ test('chokidar is installed', function (_t) { t.ok(chokidar.watch.calledOnce); t.same(chokidar.watch.firstCall.args, [ - ['package.json', '**/*.js'].concat(api.files), + ['package.json', '**/*.js'].concat(files), { ignored: defaultIgnore, ignoreInitial: true @@ -148,7 +149,7 @@ test('chokidar is installed', function (_t) { t.ok(chokidar.watch.calledOnce); t.same(chokidar.watch.firstCall.args, [ - ['foo.js', 'baz.js'].concat(api.files), + ['foo.js', 'baz.js'].concat(files), { ignored: ['bar.js', 'qux.js'], ignoreInitial: true @@ -162,7 +163,7 @@ test('chokidar is installed', function (_t) { t.ok(chokidar.watch.calledOnce); t.same(chokidar.watch.firstCall.args, [ - ['foo.js', 'baz.js'].concat(api.files), + ['foo.js', 'baz.js'].concat(files), { ignored: defaultIgnore, ignoreInitial: true @@ -180,7 +181,7 @@ test('chokidar is installed', function (_t) { start(); t.ok(api.run.calledOnce); - t.same(api.run.firstCall.args, []); + t.same(api.run.firstCall.args, [files]); // finish is only called after the run promise fulfils. t.ok(logger.finish.notCalled); @@ -229,7 +230,7 @@ test('chokidar is installed', function (_t) { // reset is called before the second run. t.ok(logger.reset.calledBefore(api.run.secondCall)); // no explicit files are provided. - t.same(api.run.secondCall.args, []); + t.same(api.run.secondCall.args, [files]); // finish is only called after the run promise fulfils. t.ok(logger.finish.calledOnce); @@ -378,7 +379,7 @@ test('chokidar is installed', function (_t) { return debounce(2).then(function () { t.ok(api.run.calledTwice); // no explicit files are provided. - t.same(api.run.secondCall.args, []); + t.same(api.run.secondCall.args, [files]); }); }); @@ -397,7 +398,7 @@ test('chokidar is installed', function (_t) { test('determines whether changed files are tests based on the initial files patterns', function (t) { t.plan(2); - api.files = ['foo-{bar,baz}.js']; + files = ['foo-{bar,baz}.js']; api.run.returns(Promise.resolve()); start(); @@ -412,7 +413,7 @@ test('chokidar is installed', function (_t) { test('initial exclude patterns override whether something is a test file', function (t) { t.plan(2); - api.files = ['foo-{bar,baz}.js']; + files = ['foo-{bar,baz}.js']; api.excludePatterns = ['!*bar*']; api.run.returns(Promise.resolve()); start(); @@ -423,14 +424,14 @@ test('chokidar is installed', function (_t) { t.ok(api.run.calledTwice); // foo-bar.js is excluded from being a test file, thus the initial tests // are run. - t.same(api.run.secondCall.args, []); + t.same(api.run.secondCall.args, [files]); }); }); test('test files must end in .js', function (t) { t.plan(2); - api.files = ['foo.bar']; + files = ['foo.bar']; api.run.returns(Promise.resolve()); start(); @@ -438,7 +439,7 @@ test('chokidar is installed', function (_t) { return debounce(2).then(function () { t.ok(api.run.calledTwice); // foo.bar cannot be a test file, thus the initial tests are run. - t.same(api.run.secondCall.args, []); + t.same(api.run.secondCall.args, [files]); }); }); @@ -453,14 +454,14 @@ test('chokidar is installed', function (_t) { return debounce(2).then(function () { t.ok(api.run.calledTwice); // _foo.bar cannot be a test file, thus the initial tests are run. - t.same(api.run.secondCall.args, []); + t.same(api.run.secondCall.args, [files]); }); }); test('files patterns may match directories', function (t) { t.plan(2); - api.files = ['dir', 'dir2/*/dir3']; + files = ['dir', 'dir2/*/dir3']; api.run.returns(Promise.resolve()); start(); @@ -475,7 +476,7 @@ test('chokidar is installed', function (_t) { test('exclude patterns override directory matches', function (t) { t.plan(2); - api.files = ['dir']; + files = ['dir']; api.excludePatterns = ['!**/exclude/**']; api.run.returns(Promise.resolve()); start(); @@ -485,7 +486,7 @@ test('chokidar is installed', function (_t) { t.ok(api.run.calledTwice); // dir/exclude/foo.js is excluded from being a test file, thus the initial // tests are run. - t.same(api.run.secondCall.args, []); + t.same(api.run.secondCall.args, [files]); }); });