diff --git a/test/cli.js b/test/cli.js index 01aa39e7d1..8b35124404 100644 --- a/test/cli.js +++ b/test/cli.js @@ -141,7 +141,7 @@ test('babel require hook only applies to the test file', t => { test('throwing a anonymous function will report the function to the console', t => { execCli('fixture/throw-anonymous-function.js', (err, stdout, stderr) => { t.ok(err); - t.match(stderr, /function \(\) \{\}/); + t.match(stderr, /\(\) => \{\}/); // TODO(jamestalmage) // t.ok(/1 uncaught exception[^s]/.test(stdout)); t.end(); diff --git a/test/fixture/_generate_source-map-initial.js b/test/fixture/_generate_source-map-initial.js index 8c3532a696..261caabbc0 100644 --- a/test/fixture/_generate_source-map-initial.js +++ b/test/fixture/_generate_source-map-initial.js @@ -1,22 +1,23 @@ 'use strict'; +const fs = require('fs'); +const path = require('path'); +const babel = require('babel-core'); -var babel = require('babel-core'); -var fs = require('fs'); -var path = require('path'); +const transformed = babel.transform(` +import {mapFile} from 'source-map-fixtures'; +import test from '../../'; -var transformed = babel.transform([ - "import { mapFile } from 'source-map-fixtures'", - "import test from '../../'", - "const fixture = mapFile('throws').require()", - // The uncaught exception is passed to the corresponding cli test. The line - // numbers from the 'throws' fixture (which uses a map file), as well as the - // line of the fixture.run() call, should match the source lines from this - // string. - "test('throw an uncaught exception', t => {", - " setImmediate(run)", - "})", - "const run = () => fixture.run()" -].join('\n'), { +const fixture = mapFile('throws').require(); + +// The uncaught exception is passed to the corresponding cli test. The line +// numbers from the 'throws' fixture (which uses a map file), as well as the +// line of the fixture.run() call, should match the source lines from this +// string. +test('throw an uncaught exception', t => { + setImmediate(run); +}) +const run = () => fixture.run(); +`, { filename: 'source-map-initial-input.js', sourceMaps: true }); @@ -27,4 +28,5 @@ fs.writeFileSync( fs.writeFileSync( path.join(__dirname, 'source-map-initial.js.map'), JSON.stringify(transformed.map)); + console.log('Generated source-map-initial.js'); diff --git a/test/fixture/async-await.js b/test/fixture/async-await.js index d20468abbd..f8600c0e81 100644 --- a/test/fixture/async-await.js +++ b/test/fixture/async-await.js @@ -2,16 +2,12 @@ import test from '../../'; test('async function', async function (t) { t.plan(1); - const value = await Promise.resolve(1); - t.is(value, 1); }); test('arrow async function', async t => { t.plan(1); - const value = await Promise.resolve(1); - t.is(value, 1); }); diff --git a/test/fixture/ava-paths/target/test.js b/test/fixture/ava-paths/target/test.js index 3d195b6f60..137bcd035f 100644 --- a/test/fixture/ava-paths/target/test.js +++ b/test/fixture/ava-paths/target/test.js @@ -1,5 +1,6 @@ -/* eslint-disable import/no-extraneous-dependencies */ -/* eslint-disable import/no-unresolved */ +/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved */ import test from 'ava'; -test(t => t.pass()); +test(t => { + t.pass(); +}); diff --git a/test/fixture/babel-plugin-foo-to-bar.js b/test/fixture/babel-plugin-foo-to-bar.js index 26d515633c..b84947e955 100644 --- a/test/fixture/babel-plugin-foo-to-bar.js +++ b/test/fixture/babel-plugin-foo-to-bar.js @@ -1,11 +1,18 @@ -module.exports = function (babel) { - var t = babel.types; +'use strict'; + +function isRequire(path) { + return path.isCallExpression() && path.get('callee').isIdentifier() && (path.get('callee').node.name === 'require'); +} + +module.exports = babel => { + const t = babel.types; return { visitor: { - CallExpression: function (path) { + CallExpression: path => { // skip require calls var firstArg = path.get('arguments')[0]; + if (!isRequire(path) && firstArg && firstArg.isStringLiteral() && /foo/i.test(firstArg.node.value)) { firstArg.replaceWith(t.stringLiteral(firstArg.node.value.replace('foo', 'bar').replace('FOO', 'BAR'))); } @@ -13,7 +20,3 @@ module.exports = function (babel) { } }; }; - -function isRequire(path) { - return path.isCallExpression() && path.get('callee').isIdentifier() && (path.get('callee').node.name === 'require'); -} diff --git a/test/fixture/babel-plugin-test-capitalizer.js b/test/fixture/babel-plugin-test-capitalizer.js index 8d05b5f486..5ec0061899 100644 --- a/test/fixture/babel-plugin-test-capitalizer.js +++ b/test/fixture/babel-plugin-test-capitalizer.js @@ -1,11 +1,18 @@ -module.exports = function (babel) { - var t = babel.types; +'use strict'; + +function isRequire(path) { + return path.isCallExpression() && path.get('callee').isIdentifier() && (path.get('callee').node.name === 'require'); +} + +module.exports = babel => { + const t = babel.types; return { visitor: { - CallExpression: function (path) { + CallExpression: path => { // skip require calls - var firstArg = path.get('arguments')[0]; + const firstArg = path.get('arguments')[0]; + if (!isRequire(path) && firstArg && firstArg.isStringLiteral() && !/repeated test/.test(firstArg.node.value)) { firstArg.replaceWith(t.stringLiteral(firstArg.node.value.toUpperCase())); } @@ -13,7 +20,3 @@ module.exports = function (babel) { } }; }; - -function isRequire(path) { - return path.isCallExpression() && path.get('callee').isIdentifier() && (path.get('callee').node.name === 'require'); -} diff --git a/test/fixture/babel-plugin-test-doubler.js b/test/fixture/babel-plugin-test-doubler.js index 279dcb9413..c551e52cef 100644 --- a/test/fixture/babel-plugin-test-doubler.js +++ b/test/fixture/babel-plugin-test-doubler.js @@ -1,3 +1,4 @@ +'use strict'; /* A Babel plugin that causes each AVA test to be duplicated with a new title. @@ -11,28 +12,31 @@ This is used by some integration tests to validate correct handling of Babel config options. */ -function plugin(babel) { - var t = babel.types; - var anonCount = 1; +module.exports = babel => { + const t = babel.types; + const anonCount = 1; return { visitor: { - CallExpression: function (path) { - var node = path.node; - var callee = node.callee; - var args = node.arguments; + CallExpression: path => { + const node = path.node; + const callee = node.callee; + let args = node.arguments; + if (callee.type === 'Identifier' && callee.name === 'test') { if (args.length === 1) { - args = [t.StringLiteral('repeated test: anonymous' + anonCount++), args[0]]; + args = [t.StringLiteral(`repeated test: anonymous${anonCount++}`), args[0]]; } else if (args.length === 2 && args[0].type === 'StringLiteral') { if (/^repeated test/.test(args[0].value)) { return; } + args = args.slice(); - args[0] = t.StringLiteral('repeated test: ' + args[0].value); + args[0] = t.StringLiteral(`repeated test: ${args[0].value}`); } else { - throw new Error('the plugin does not know how to handle this call to test'); + throw new Error('The plugin does not know how to handle this call to test'); } + path.insertAfter(t.CallExpression( t.Identifier('test'), args @@ -41,6 +45,4 @@ function plugin(babel) { } } }; -} - -module.exports = plugin; +}; diff --git a/test/fixture/caching/test.js b/test/fixture/caching/test.js index e50e274793..8bd357561e 100644 --- a/test/fixture/caching/test.js +++ b/test/fixture/caching/test.js @@ -1,3 +1,5 @@ -import test from '../../../' +import test from '../../../'; -test(t => t.true(2 + 2 === 4)); +test(t => { + t.true(2 + 2 === 4); +}); diff --git a/test/fixture/destructuring-public-api.js b/test/fixture/destructuring-public-api.js index cb919ed0fb..961a2d7ed5 100644 --- a/test/fixture/destructuring-public-api.js +++ b/test/fixture/destructuring-public-api.js @@ -1,17 +1,19 @@ import test from '../../'; -test.beforeEach(t => t.context = 'bar'); +test.beforeEach(t => { + t.context = 'bar'; +}); -test.cb('callback mode', ({context: foo, ... t}) => { +test.cb('callback mode', ({context: foo, ...t}) => { t.is(foo, 'bar'); t.end(); }); -test.cb('callback mode #2', ({context: foo, end, ... t}) => { +test.cb('callback mode #2', ({context: foo, end, ...t}) => { t.is(foo, 'bar'); end(); }); -test('sync', ({context: foo, ... t}) => { +test('sync', ({context: foo, ...t}) => { t.is(foo, 'bar'); }); diff --git a/test/fixture/exclusive-nonexclusive.js b/test/fixture/exclusive-nonexclusive.js index e0d1fbbf95..77d5a0384f 100644 --- a/test/fixture/exclusive-nonexclusive.js +++ b/test/fixture/exclusive-nonexclusive.js @@ -1,9 +1,9 @@ import test from '../../'; test.only(t => { - t.pass(); + t.pass(); }); test(t => { - t.fail(); + t.fail(); }); diff --git a/test/fixture/exclusive.js b/test/fixture/exclusive.js index 3060d8b66b..2930ac13c5 100644 --- a/test/fixture/exclusive.js +++ b/test/fixture/exclusive.js @@ -1,5 +1,5 @@ import test from '../../'; test.only(t => { - t.pass(); + t.pass(); }); diff --git a/test/fixture/fake-timers.js b/test/fixture/fake-timers.js index 68e4b06e7f..599a4b0744 100644 --- a/test/fixture/fake-timers.js +++ b/test/fixture/fake-timers.js @@ -1,5 +1,5 @@ -import test from '../../'; import sinon from 'sinon'; +import test from '../../'; test(t => { sinon.useFakeTimers(Date.now() + 10000); diff --git a/test/fixture/generators.js b/test/fixture/generators.js index 4ff185ecca..0b807f378c 100644 --- a/test/fixture/generators.js +++ b/test/fixture/generators.js @@ -2,8 +2,6 @@ import test from '../../'; test('generator function', function * (t) { t.plan(1); - const value = yield Promise.resolve(1); - t.is(value, 1); }); diff --git a/test/fixture/immediate-0-exit.js b/test/fixture/immediate-0-exit.js index dcbbff6c93..116cb2e931 100644 --- a/test/fixture/immediate-0-exit.js +++ b/test/fixture/immediate-0-exit.js @@ -1 +1,2 @@ +'use strict'; process.exit(0); diff --git a/test/fixture/immediate-3-exit.js b/test/fixture/immediate-3-exit.js index cd0920add6..81d2fa1a94 100644 --- a/test/fixture/immediate-3-exit.js +++ b/test/fixture/immediate-3-exit.js @@ -1 +1,2 @@ +'use strict'; process.exit(3); diff --git a/test/fixture/improper-t-throws-unhandled-rejection.js b/test/fixture/improper-t-throws-unhandled-rejection.js index 5cfbc3014e..39a487d1ef 100644 --- a/test/fixture/improper-t-throws-unhandled-rejection.js +++ b/test/fixture/improper-t-throws-unhandled-rejection.js @@ -4,7 +4,7 @@ test.cb(t => { Promise.resolve().then(() => { t.throws(throwSync()); }); - + setTimeout(t.end, 20); }); diff --git a/test/fixture/install-global.js b/test/fixture/install-global.js index 55ec32fb53..22de4db13a 100644 --- a/test/fixture/install-global.js +++ b/test/fixture/install-global.js @@ -1 +1,2 @@ +'use strict'; global.foo = 'bar'; diff --git a/test/fixture/long-running.js b/test/fixture/long-running.js index 9400a82c6d..f10ae198c3 100644 --- a/test/fixture/long-running.js +++ b/test/fixture/long-running.js @@ -4,6 +4,4 @@ test.cb('slow', t => { setTimeout(t.end, 5000); }); -test('fast', t => { - -}); +test('fast', () => {}); diff --git a/test/fixture/loud-rejection.js b/test/fixture/loud-rejection.js index 8a5fa1244e..f96fe0e048 100644 --- a/test/fixture/loud-rejection.js +++ b/test/fixture/loud-rejection.js @@ -1,7 +1,7 @@ import test from '../../'; test.cb('creates an unhandled rejection', t => { - Promise.reject(new Error(`You can't handle this!`)); + Promise.reject(new Error('You can\'t handle this!')); setTimeout(() => { t.end(); diff --git a/test/fixture/node-paths.js b/test/fixture/node-paths.js index 192858d9c7..16092e198a 100644 --- a/test/fixture/node-paths.js +++ b/test/fixture/node-paths.js @@ -1,6 +1,6 @@ -import test from '../../'; import foo from 'nested/foo'; import bar from 'path/bar'; +import test from '../../'; test('relative require', t => { t.is(foo, 'bar'); diff --git a/test/fixture/node-paths/deep/nested/path/bar.js b/test/fixture/node-paths/deep/nested/path/bar.js index f24e54fd07..802f406914 100644 --- a/test/fixture/node-paths/deep/nested/path/bar.js +++ b/test/fixture/node-paths/deep/nested/path/bar.js @@ -1 +1,2 @@ +'use strict'; module.exports = 'baz'; diff --git a/test/fixture/node-paths/modules/nested/foo.js b/test/fixture/node-paths/modules/nested/foo.js index cb1c2c01e7..595e376740 100644 --- a/test/fixture/node-paths/modules/nested/foo.js +++ b/test/fixture/node-paths/modules/nested/foo.js @@ -1 +1,2 @@ +'use strict'; module.exports = 'bar'; diff --git a/test/fixture/observable.js b/test/fixture/observable.js deleted file mode 100644 index 62ea402c24..0000000000 --- a/test/fixture/observable.js +++ /dev/null @@ -1,13 +0,0 @@ -var Promise = require('bluebird'); - -// global Promise for zen-observable -if (!global.Promise) { - Object.defineProperty(global, 'Promise', { - value: Promise, - configurable: true, - enumerable: false, - writable: true - }); -} - -module.exports = require('zen-observable'); diff --git a/test/fixture/pkg-conf/defaults/test.js b/test/fixture/pkg-conf/defaults/test.js index b5464b732b..c209f3b688 100644 --- a/test/fixture/pkg-conf/defaults/test.js +++ b/test/fixture/pkg-conf/defaults/test.js @@ -1,4 +1,4 @@ -import test from '../../../../' +import test from '../../../../'; const opts = JSON.parse(process.argv[2]); diff --git a/test/fixture/pkg-conf/pkg-overrides/actual.js b/test/fixture/pkg-conf/pkg-overrides/actual.js index b7e33491e0..ad57937f09 100644 --- a/test/fixture/pkg-conf/pkg-overrides/actual.js +++ b/test/fixture/pkg-conf/pkg-overrides/actual.js @@ -1,5 +1,5 @@ -import test from '../../../../'; import path from 'path'; +import test from '../../../../'; const opts = JSON.parse(process.argv[2]); diff --git a/test/fixture/pkg-conf/pkg-overrides/required.js b/test/fixture/pkg-conf/pkg-overrides/required.js index 4223475124..8a292376aa 100644 --- a/test/fixture/pkg-conf/pkg-overrides/required.js +++ b/test/fixture/pkg-conf/pkg-overrides/required.js @@ -1,3 +1,2 @@ 'use strict'; - module.exports = 'foo'; diff --git a/test/fixture/pkg-conf/precedence/c.js b/test/fixture/pkg-conf/precedence/c.js index 45abfe2ea4..f2a60ca21f 100644 --- a/test/fixture/pkg-conf/precedence/c.js +++ b/test/fixture/pkg-conf/precedence/c.js @@ -1,5 +1,5 @@ -import test from '../../../../'; import path from 'path'; +import test from '../../../../'; const opts = JSON.parse(process.argv[2]); diff --git a/test/fixture/pkg-conf/precedence/default-required.js b/test/fixture/pkg-conf/precedence/default-required.js index a7f281456c..595e376740 100644 --- a/test/fixture/pkg-conf/precedence/default-required.js +++ b/test/fixture/pkg-conf/precedence/default-required.js @@ -1 +1,2 @@ -module.exports = "bar"; +'use strict'; +module.exports = 'bar'; diff --git a/test/fixture/pkg-conf/precedence/required.js b/test/fixture/pkg-conf/precedence/required.js index 4223475124..8a292376aa 100644 --- a/test/fixture/pkg-conf/precedence/required.js +++ b/test/fixture/pkg-conf/precedence/required.js @@ -1,3 +1,2 @@ 'use strict'; - module.exports = 'foo'; diff --git a/test/fixture/power-assert.js b/test/fixture/power-assert.js index c494e7258c..f30554a62e 100644 --- a/test/fixture/power-assert.js +++ b/test/fixture/power-assert.js @@ -2,24 +2,23 @@ import test from '../../'; test.serial(t => { const a = 'foo'; - t.true(a === 'bar'); }); test.serial(t => { const a = 'bar'; - t.true(a === 'foo', 'with message'); }); test.serial(t => { const o = {}; - t.true(o === {...o}); }); test.serial(t => { - const React = { createElement: function(type) { return type } } + const React = { + createElement: type => type + }; t.true(
=== ); }); diff --git a/test/fixture/serial.js b/test/fixture/serial.js index 29aee03d16..20332425c0 100644 --- a/test/fixture/serial.js +++ b/test/fixture/serial.js @@ -1,6 +1,6 @@ import test from '../../'; -var tests = []; +const tests = []; test.cb('first', t => { setTimeout(() => { diff --git a/test/fixture/slow-exit.js b/test/fixture/slow-exit.js index d92e88408e..24523f34d1 100644 --- a/test/fixture/slow-exit.js +++ b/test/fixture/slow-exit.js @@ -1,5 +1,5 @@ -import test from '../../'; import signalExit from 'signal-exit'; +import test from '../../'; test.cb('long running', t => { t.plan(1); diff --git a/test/fixture/throw-anonymous-function.js b/test/fixture/throw-anonymous-function.js index 365b6bb071..a553e5ae35 100644 --- a/test/fixture/throw-anonymous-function.js +++ b/test/fixture/throw-anonymous-function.js @@ -2,6 +2,6 @@ import test from '../../'; test('throw an uncaught exception', () => { setImmediate(() => { - throw function () {}; + throw () => {}; }); }); diff --git a/test/fixture/with-dependencies/require-custom.js b/test/fixture/with-dependencies/require-custom.js index 052ac2550f..e45f9ad5ae 100644 --- a/test/fixture/with-dependencies/require-custom.js +++ b/test/fixture/with-dependencies/require-custom.js @@ -1 +1 @@ -require.extensions['.custom'] = require.extensions['.js'] +require.extensions['.custom'] = require.extensions['.js']; diff --git a/test/observable.js b/test/observable.js index 9bb2bef135..c1acba9c69 100644 --- a/test/observable.js +++ b/test/observable.js @@ -1,7 +1,7 @@ 'use strict'; const test = require('tap').test; +const Observable = require('zen-observable'); const Test = require('../lib/test'); -const Observable = require('./fixture/observable'); function ava(fn) { const a = new Test(fn);