From ef1b8a0b910b81070a600c8c772434ec345812dd Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Sun, 19 Jan 2020 15:22:52 +0000 Subject: [PATCH] chore(package): update ava to version 3.1.0 --- package.json | 6 +- test/branches/branches.test.js | 10 +-- test/branches/expand.test.js | 6 +- test/branches/get-tags.test.js | 8 +-- test/branches/normalize.test.js | 4 +- test/cli.test.js | 32 +++++---- test/definitions/branches.test.js | 4 +- test/definitions/plugins.test.js | 6 +- test/get-commits.test.js | 8 +-- test/get-config.test.js | 104 +++++++++++++++--------------- test/get-git-auth-url.test.js | 6 +- test/get-last-release.test.js | 6 +- test/get-logger.test.js | 6 +- test/get-next-version.test.js | 6 +- test/get-release-to-add.test.js | 8 +-- test/git.test.js | 14 ++-- test/helpers/git-utils.js | 83 +++++++++++++++--------- test/helpers/gitbox.js | 10 +-- test/helpers/mockserver.js | 12 ++-- test/helpers/npm-registry.js | 12 ++-- test/helpers/npm-utils.js | 6 +- test/hide-sensitive.test.js | 8 +-- test/index.test.js | 27 ++++---- test/integration.test.js | 30 ++++----- test/plugins/normalize.test.js | 20 +++--- test/plugins/pipeline.test.js | 13 ++-- test/plugins/plugins.test.js | 12 ++-- test/plugins/utils.test.js | 4 +- test/utils.test.js | 8 +-- test/verify.test.js | 8 +-- 30 files changed, 255 insertions(+), 232 deletions(-) diff --git a/package.json b/package.json index cb8c610d05..22f47c2dbd 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,7 @@ "files": [ "test/**/*.test.js" ], - "helpers": [ - "test/helpers/**/*" - ] + "timeout": "2m" }, "bin": { "semantic-release": "bin/semantic-release.js" @@ -52,7 +50,7 @@ "yargs": "^15.0.1" }, "devDependencies": { - "ava": "^2.0.0", + "ava": "^3.1.0", "clear-module": "^4.0.0", "codecov": "^3.0.0", "delay": "^4.0.0", diff --git a/test/branches/branches.test.js b/test/branches/branches.test.js index a87bbba790..3432b5e84b 100644 --- a/test/branches/branches.test.js +++ b/test/branches/branches.test.js @@ -1,7 +1,7 @@ -import test from 'ava'; -import {union} from 'lodash'; -import semver from 'semver'; -import proxyquire from 'proxyquire'; +const test = require('ava'); +const {union} = require('lodash'); +const semver = require('semver'); +const proxyquire = require('proxyquire'); const getBranch = (branches, branch) => branches.find(({name}) => name === branch); const release = (branches, name, version) => getBranch(branches, name).tags.push({version}); @@ -135,7 +135,7 @@ test('Enforce ranges with branching release workflow', async t => { t.is( getBranch(result, '1.0.x').range, '>=1.0.1 <1.0.2', - 'Cannot release on 1.0.x before 1.0.x version from master are merged' + 'Cannot release on 1.0.x before 1.0.x version = require(master are merged' ); t.is(getBranch(result, '1.x').range, '>=1.1.0 <1.0.2', 'Cannot release on 1.x before >= 2.0.0 is released on master'); diff --git a/test/branches/expand.test.js b/test/branches/expand.test.js index a912e193da..95105085f6 100644 --- a/test/branches/expand.test.js +++ b/test/branches/expand.test.js @@ -1,6 +1,6 @@ -import test from 'ava'; -import expand from '../../lib/branches/expand'; -import {gitRepo, gitCommits, gitCheckout, gitPush} from '../helpers/git-utils'; +const test = require('ava'); +const expand = require('../../lib/branches/expand'); +const {gitRepo, gitCommits, gitCheckout, gitPush} = require('../helpers/git-utils'); test('Expand branches defined with globs', async t => { const {cwd, repositoryUrl} = await gitRepo(true); diff --git a/test/branches/get-tags.test.js b/test/branches/get-tags.test.js index 7321f92323..171c66df9e 100644 --- a/test/branches/get-tags.test.js +++ b/test/branches/get-tags.test.js @@ -1,6 +1,6 @@ -import test from 'ava'; -import getTags from '../../lib/branches/get-tags'; -import {gitRepo, gitCommits, gitTagVersion, gitCheckout, gitAddNote} from '../helpers/git-utils'; +const test = require('ava'); +const getTags = require('../../lib/branches/get-tags'); +const {gitRepo, gitCommits, gitTagVersion, gitCheckout, gitAddNote} = require('../helpers/git-utils'); test('Get the valid tags', async t => { const {cwd} = await gitRepo(); @@ -28,7 +28,7 @@ test('Get the valid tags', async t => { ]); }); -test('Get the valid tags from multiple branches', async t => { +test('Get the valid tags = require(multiple branches', async t => { const {cwd} = await gitRepo(); await gitCommits(['First'], {cwd}); await gitTagVersion('v1.0.0', undefined, {cwd}); diff --git a/test/branches/normalize.test.js b/test/branches/normalize.test.js index 765ec866ae..1e74a1019a 100644 --- a/test/branches/normalize.test.js +++ b/test/branches/normalize.test.js @@ -1,5 +1,5 @@ -import test from 'ava'; -import normalize from '../../lib/branches/normalize'; +const test = require('ava'); +const normalize = require('../../lib/branches/normalize'); const toTags = versions => versions.map(version => ({version})); diff --git a/test/cli.test.js b/test/cli.test.js index ee713addaf..0a198122f5 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -1,10 +1,8 @@ -import test from 'ava'; -import {escapeRegExp} from 'lodash'; -import proxyquire from 'proxyquire'; -import {stub} from 'sinon'; -import {SECRET_REPLACEMENT} from '../lib/definitions/constants'; - -const requireNoCache = proxyquire.noPreserveCache(); +const test = require('ava'); +const {escapeRegExp} = require('lodash'); +const proxyquire = require('proxyquire').noPreserveCache(); +const {stub} = require('sinon'); +const {SECRET_REPLACEMENT} = require('../lib/definitions/constants'); test.beforeEach(t => { t.context.logs = ''; @@ -65,7 +63,7 @@ test.serial('Pass options to semantic-release API', async t => { '--debug', '-d', ]; - const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); + const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const exitCode = await cli(); @@ -107,7 +105,7 @@ test.serial('Pass options to semantic-release API with alias arguments', async t 'config2', '--dry-run', ]; - const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); + const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const exitCode = await cli(); @@ -124,7 +122,7 @@ test.serial('Pass options to semantic-release API with alias arguments', async t test.serial('Pass unknown options to semantic-release API', async t => { const run = stub().resolves(true); const argv = ['', '', '--bool', '--first-option', 'value1', '--second-option', 'value2', '--second-option', 'value3']; - const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); + const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const exitCode = await cli(); @@ -138,7 +136,7 @@ test.serial('Pass unknown options to semantic-release API', async t => { test.serial('Pass empty Array to semantic-release API for list option set to "false"', async t => { const run = stub().resolves(true); const argv = ['', '', '--publish', 'false']; - const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); + const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const exitCode = await cli(); @@ -150,7 +148,7 @@ test.serial('Pass empty Array to semantic-release API for list option set to "fa test.serial('Do not set properties in option for which arg is not in command line', async t => { const run = stub().resolves(true); const argv = ['', '', '-b', 'master']; - const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); + const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); await cli(); @@ -167,7 +165,7 @@ test.serial('Do not set properties in option for which arg is not in command lin test.serial('Display help', async t => { const run = stub().resolves(true); const argv = ['', '', '--help']; - const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); + const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const exitCode = await cli(); @@ -178,7 +176,7 @@ test.serial('Display help', async t => { test.serial('Return error exitCode and prints help if called with a command', async t => { const run = stub().resolves(true); const argv = ['', '', 'pre']; - const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); + const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const exitCode = await cli(); @@ -190,7 +188,7 @@ test.serial('Return error exitCode and prints help if called with a command', as test.serial('Return error exitCode if multiple plugin are set for single plugin', async t => { const run = stub().resolves(true); const argv = ['', '', '--analyze-commits', 'analyze1', 'analyze2']; - const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); + const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const exitCode = await cli(); @@ -202,7 +200,7 @@ test.serial('Return error exitCode if multiple plugin are set for single plugin' test.serial('Return error exitCode if semantic-release throw error', async t => { const run = stub().rejects(new Error('semantic-release error')); const argv = ['', '']; - const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); + const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const exitCode = await cli(); @@ -214,7 +212,7 @@ test.serial('Hide sensitive environment variable values from the logs', async t const env = {MY_TOKEN: 'secret token'}; const run = stub().rejects(new Error(`Throw error: Exposing token ${env.MY_TOKEN}`)); const argv = ['', '']; - const cli = requireNoCache('../cli', {'.': run, process: {...process, argv, env: {...process.env, ...env}}}); + const cli = proxyquire('../cli', {'.': run, process: {...process, argv, env: {...process.env, ...env}}}); const exitCode = await cli(); diff --git a/test/definitions/branches.test.js b/test/definitions/branches.test.js index 222334d054..7dccb235e9 100644 --- a/test/definitions/branches.test.js +++ b/test/definitions/branches.test.js @@ -1,5 +1,5 @@ -import test from 'ava'; -import {maintenance, prerelease, release} from '../../lib/definitions/branches'; +const test = require('ava'); +const {maintenance, prerelease, release} = require('../../lib/definitions/branches'); test('A "maintenance" branch is identified by having a "range" property or a "name" formatted like "N.x", "N.x.x" or "N.N.x"', t => { t.true(maintenance.filter({name: '1.x.x'})); diff --git a/test/definitions/plugins.test.js b/test/definitions/plugins.test.js index 0a6de485df..f7d21a94ba 100644 --- a/test/definitions/plugins.test.js +++ b/test/definitions/plugins.test.js @@ -1,6 +1,6 @@ -import test from 'ava'; -import plugins from '../../lib/definitions/plugins'; -import {RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT} from '../../lib/definitions/constants'; +const test = require('ava'); +const plugins = require('../../lib/definitions/plugins'); +const {RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT} = require('../../lib/definitions/constants'); test('The "analyzeCommits" plugin output must be either undefined or a valid semver release type', t => { t.false(plugins.analyzeCommits.outputValidator('invalid')); diff --git a/test/get-commits.test.js b/test/get-commits.test.js index 5313f917a6..fb7cbe5622 100644 --- a/test/get-commits.test.js +++ b/test/get-commits.test.js @@ -1,7 +1,7 @@ -import test from 'ava'; -import {stub} from 'sinon'; -import getCommits from '../lib/get-commits'; -import {gitRepo, gitCommits, gitDetachedHead} from './helpers/git-utils'; +const test = require('ava'); +const {stub} = require('sinon'); +const getCommits = require('../lib/get-commits'); +const {gitRepo, gitCommits, gitDetachedHead} = require('./helpers/git-utils'); test.beforeEach(t => { // Stub the logger functions diff --git a/test/get-config.test.js b/test/get-config.test.js index 80fd72d064..101f3e59fe 100644 --- a/test/get-config.test.js +++ b/test/get-config.test.js @@ -1,12 +1,12 @@ -import path from 'path'; -import {format} from 'util'; -import test from 'ava'; -import {writeFile, outputJson} from 'fs-extra'; -import {omit} from 'lodash'; -import proxyquire from 'proxyquire'; -import {stub} from 'sinon'; -import yaml from 'js-yaml'; -import {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} from './helpers/git-utils'; +const path = require('path'); +const {format} = require('util'); +const test = require('ava'); +const {writeFile, outputJson} = require('fs-extra'); +const {omit} = require('lodash'); +const proxyquire = require('proxyquire'); +const {stub} = require('sinon'); +const yaml = require('js-yaml'); +const {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} = require('./helpers/git-utils'); const DEFAULT_PLUGINS = [ '@semantic-release/commit-analyzer', @@ -20,7 +20,7 @@ test.beforeEach(t => { t.context.getConfig = proxyquire('../lib/get-config', {'./plugins': t.context.plugins}); }); -test('Default values, reading repositoryUrl from package.json', async t => { +test('Default values, reading repositoryUrl = require(package.json', async t => { const pkg = {repository: 'https://host.null/owner/package.git'}; // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(true); @@ -47,7 +47,7 @@ test('Default values, reading repositoryUrl from package.json', async t => { t.is(result.tagFormat, `v\${version}`); }); -test('Default values, reading repositoryUrl from repo if not set in package.json', async t => { +test('Default values, reading repositoryUrl = require(repo if not set in package.json', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(true); // Add remote.origin.url config @@ -68,7 +68,7 @@ test('Default values, reading repositoryUrl from repo if not set in package.json t.is(result.tagFormat, `v\${version}`); }); -test('Default values, reading repositoryUrl (http url) from package.json if not set in repo', async t => { +test('Default values, reading repositoryUrl (http url) = require(package.json if not set in repo', async t => { const pkg = {repository: 'https://host.null/owner/module.git'}; // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); @@ -102,7 +102,7 @@ test('Convert "ci" option to "noCi"', async t => { t.is(result.noCi, true); }); -test('Read options from package.json', async t => { +test('Read options = require(package.json', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); const options = { @@ -119,13 +119,13 @@ test('Read options from package.json', async t => { const {options: result} = await t.context.getConfig({cwd}); const expected = {...options, branches: ['test_branch']}; - // Verify the options contains the plugin config from package.json + // Verify the options contains the plugin config = require(package.json t.deepEqual(result, expected); - // Verify the plugins module is called with the plugin options from package.json + // Verify the plugins module is called with the plugin options = require(package.json t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); }); -test('Read options from .releaserc.yml', async t => { +test('Read options = require(.releaserc.yml', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); const options = { @@ -141,13 +141,13 @@ test('Read options from .releaserc.yml', async t => { const {options: result} = await t.context.getConfig({cwd}); const expected = {...options, branches: ['test_branch']}; - // Verify the options contains the plugin config from package.json + // Verify the options contains the plugin config = require(package.json t.deepEqual(result, expected); - // Verify the plugins module is called with the plugin options from package.json + // Verify the plugins module is called with the plugin options = require(package.json t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); }); -test('Read options from .releaserc.json', async t => { +test('Read options = require(.releaserc.json', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); const options = { @@ -163,13 +163,13 @@ test('Read options from .releaserc.json', async t => { const {options: result} = await t.context.getConfig({cwd}); const expected = {...options, branches: ['test_branch']}; - // Verify the options contains the plugin config from package.json + // Verify the options contains the plugin config = require(package.json t.deepEqual(result, expected); - // Verify the plugins module is called with the plugin options from package.json + // Verify the plugins module is called with the plugin options = require(package.json t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); }); -test('Read options from .releaserc.js', async t => { +test('Read options = require(.releaserc.js', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); const options = { @@ -185,13 +185,13 @@ test('Read options from .releaserc.js', async t => { const {options: result} = await t.context.getConfig({cwd}); const expected = {...options, branches: ['test_branch']}; - // Verify the options contains the plugin config from package.json + // Verify the options contains the plugin config = require(package.json t.deepEqual(result, expected); - // Verify the plugins module is called with the plugin options from package.json + // Verify the plugins module is called with the plugin options = require(package.json t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); }); -test('Read options from release.config.js', async t => { +test('Read options = require(release.config.js', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); const options = { @@ -207,9 +207,9 @@ test('Read options from release.config.js', async t => { const {options: result} = await t.context.getConfig({cwd}); const expected = {...options, branches: ['test_branch']}; - // Verify the options contains the plugin config from package.json + // Verify the options contains the plugin config = require(package.json t.deepEqual(result, expected); - // Verify the plugins module is called with the plugin options from package.json + // Verify the plugins module is called with the plugin options = require(package.json t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); }); @@ -237,13 +237,13 @@ test('Prioritise CLI/API parameters over file configuration and git repo', async const result = await t.context.getConfig({cwd}, options); const expected = {...options, branches: ['branch_cli']}; - // Verify the options contains the plugin config from CLI/API + // Verify the options contains the plugin config = require(CLI/API t.deepEqual(result.options, expected); - // Verify the plugins module is called with the plugin options from CLI/API + // Verify the plugins module is called with the plugin options = require(CLI/API t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); }); -test('Read configuration from file path in "extends"', async t => { +test('Read configuration = require(file path in "extends"', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); const pkgOptions = {extends: './shareable.json'}; @@ -262,9 +262,9 @@ test('Read configuration from file path in "extends"', async t => { const {options: result} = await t.context.getConfig({cwd}); const expected = {...options, branches: ['test_branch']}; - // Verify the options contains the plugin config from shareable.json + // Verify the options contains the plugin config = require(shareable.json t.deepEqual(result, expected); - // Verify the plugins module is called with the plugin options from shareable.json + // Verify the plugins module is called with the plugin options = require(shareable.json t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][1], { analyzeCommits: './shareable.json', @@ -274,7 +274,7 @@ test('Read configuration from file path in "extends"', async t => { }); }); -test('Read configuration from module path in "extends"', async t => { +test('Read configuration = require(module path in "extends"', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); const pkgOptions = {extends: 'shareable'}; @@ -293,9 +293,9 @@ test('Read configuration from module path in "extends"', async t => { const {options: result} = await t.context.getConfig({cwd}); const expected = {...options, branches: ['test_branch']}; - // Verify the options contains the plugin config from shareable.json + // Verify the options contains the plugin config = require(shareable.json t.deepEqual(result, expected); - // Verify the plugins module is called with the plugin options from shareable.json + // Verify the plugins module is called with the plugin options = require(shareable.json t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][1], { analyzeCommits: 'shareable', @@ -303,7 +303,7 @@ test('Read configuration from module path in "extends"', async t => { }); }); -test('Read configuration from an array of paths in "extends"', async t => { +test('Read configuration = require(an array of paths in "extends"', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); const pkgOptions = {extends: ['./shareable1.json', './shareable2.json']}; @@ -329,9 +329,9 @@ test('Read configuration from an array of paths in "extends"', async t => { const {options: result} = await t.context.getConfig({cwd}); const expected = {...options1, ...options2, branches: ['test_branch']}; - // Verify the options contains the plugin config from shareable1.json and shareable2.json + // Verify the options contains the plugin config = require(shareable1.json and shareable2.json t.deepEqual(result, expected); - // Verify the plugins module is called with the plugin options from shareable1.json and shareable2.json + // Verify the plugins module is called with the plugin options = require(shareable1.json and shareable2.json t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][1], { verifyRelease1: './shareable1.json', @@ -342,7 +342,7 @@ test('Read configuration from an array of paths in "extends"', async t => { }); }); -test('Prioritize configuration from config file over "extends"', async t => { +test('Prioritize configuration = require(config file over "extends"', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); const pkgOptions = { @@ -367,9 +367,9 @@ test('Prioritize configuration from config file over "extends"', async t => { const {options: result} = await t.context.getConfig({cwd}); const expected = omit({...options1, ...pkgOptions, branches: ['test_pkg']}, 'extends'); - // Verify the options contains the plugin config from package.json and shareable.json + // Verify the options contains the plugin config = require(package.json and shareable.json t.deepEqual(result, expected); - // Verify the plugins module is called with the plugin options from package.json and shareable.json + // Verify the plugins module is called with the plugin options = require(package.json and shareable.json t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][1], { analyzeCommits: './shareable.json', @@ -378,7 +378,7 @@ test('Prioritize configuration from config file over "extends"', async t => { }); }); -test('Prioritize configuration from cli/API options over "extends"', async t => { +test('Prioritize configuration = require(cli/API options over "extends"', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); const cliOptions = { @@ -415,9 +415,9 @@ test('Prioritize configuration from cli/API options over "extends"', async t => const {options: result} = await t.context.getConfig({cwd}, cliOptions); const expected = omit({...options2, ...pkgOptions, ...cliOptions, branches: ['branch_opts']}, 'extends'); - // Verify the options contains the plugin config from package.json and shareable2.json + // Verify the options contains the plugin config = require(package.json and shareable2.json t.deepEqual(result, expected); - // Verify the plugins module is called with the plugin options from package.json and shareable2.json + // Verify the plugins module is called with the plugin options = require(package.json and shareable2.json t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); }); @@ -443,13 +443,13 @@ test('Allow to unset properties defined in shareable config with "null"', async const {options} = await t.context.getConfig({cwd}); - // Verify the options contains the plugin config from shareable.json and the default `plugins` + // Verify the options contains the plugin config = require(shareable.json and the default `plugins` t.deepEqual(options, { ...omit(options1, ['analyzeCommits']), ...omit(pkgOptions, ['extends', 'analyzeCommits']), plugins: DEFAULT_PLUGINS, }); - // Verify the plugins module is called with the plugin options from shareable.json and the default `plugins` + // Verify the plugins module is called with the plugin options = require(shareable.json and the default `plugins` t.deepEqual(t.context.plugins.args[0][0], { options: { ...omit(options1, 'analyzeCommits'), @@ -492,9 +492,9 @@ test('Allow to unset properties defined in shareable config with "undefined"', a ...omit(pkgOptions, ['extends', 'analyzeCommits']), branches: ['test_branch'], }; - // Verify the options contains the plugin config from shareable.json + // Verify the options contains the plugin config = require(shareable.json t.deepEqual(result, expected); - // Verify the plugins module is called with the plugin options from shareable.json + // Verify the plugins module is called with the plugin options = require(shareable.json t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][1], { generateNotes: './shareable.json', @@ -511,8 +511,8 @@ test('Throw an Error if one of the shareable config cannot be found', async t => await outputJson(path.resolve(cwd, 'package.json'), {release: pkhOptions}); await outputJson(path.resolve(cwd, 'shareable1.json'), options1); - const error = await t.throwsAsync(t.context.getConfig({cwd}), Error); - - t.regex(error.message, /Cannot find module 'non-existing-path'/); - t.is(error.code, 'MODULE_NOT_FOUND'); + await t.throwsAsync(t.context.getConfig({cwd}), { + message: /Cannot find module 'non-existing-path'/, + code: 'MODULE_NOT_FOUND', + }); }); diff --git a/test/get-git-auth-url.test.js b/test/get-git-auth-url.test.js index b12933ead2..4d4ae0210a 100644 --- a/test/get-git-auth-url.test.js +++ b/test/get-git-auth-url.test.js @@ -1,6 +1,6 @@ -import test from 'ava'; -import getAuthUrl from '../lib/get-git-auth-url'; -import {gitRepo} from './helpers/git-utils'; +const test = require('ava'); +const getAuthUrl = require('../lib/get-git-auth-url'); +const {gitRepo} = require('./helpers/git-utils'); const env = {GIT_ASKPASS: 'echo', GIT_TERMINAL_PROMPT: 0}; diff --git a/test/get-last-release.test.js b/test/get-last-release.test.js index bb3a2ee26e..a3d664ed92 100644 --- a/test/get-last-release.test.js +++ b/test/get-last-release.test.js @@ -1,5 +1,5 @@ -import test from 'ava'; -import getLastRelease from '../lib/get-last-release'; +const test = require('ava'); +const getLastRelease = require('../lib/get-last-release'); test('Get the highest non-prerelease valid tag', t => { const result = getLastRelease({ @@ -18,7 +18,7 @@ test('Get the highest non-prerelease valid tag', t => { t.deepEqual(result, {version: '2.0.0', gitTag: 'v2.0.0', name: 'v2.0.0', gitHead: 'v2.0.0', channels: undefined}); }); -test('Get the highest prerelease valid tag, ignoring other tags from other prerelease channels', t => { +test('Get the highest prerelease valid tag, ignoring other tags = require(other prerelease channels', t => { const result = getLastRelease({ branch: { name: 'beta', diff --git a/test/get-logger.test.js b/test/get-logger.test.js index 31e756288f..662e13871a 100644 --- a/test/get-logger.test.js +++ b/test/get-logger.test.js @@ -1,6 +1,6 @@ -import test from 'ava'; -import {spy} from 'sinon'; -import getLogger from '../lib/get-logger'; +const test = require('ava'); +const {spy} = require('sinon'); +const getLogger = require('../lib/get-logger'); test('Expose "error", "success" and "log" functions', t => { const stdout = spy(); diff --git a/test/get-next-version.test.js b/test/get-next-version.test.js index 2bd808d1ee..6e07355a44 100644 --- a/test/get-next-version.test.js +++ b/test/get-next-version.test.js @@ -1,6 +1,6 @@ -import test from 'ava'; -import {stub} from 'sinon'; -import getNextVersion from '../lib/get-next-version'; +const test = require('ava'); +const {stub} = require('sinon'); +const getNextVersion = require('../lib/get-next-version'); test.beforeEach(t => { // Stub the logger functions diff --git a/test/get-release-to-add.test.js b/test/get-release-to-add.test.js index 823e281792..edadf1b150 100644 --- a/test/get-release-to-add.test.js +++ b/test/get-release-to-add.test.js @@ -1,7 +1,7 @@ -import test from 'ava'; -import getReleaseToAdd from '../lib/get-release-to-add'; +const test = require('ava'); +const getReleaseToAdd = require('../lib/get-release-to-add'); -test('Return versions merged from release to maintenance branch, excluding lower than branch start range', t => { +test('Return versions merged = require(release to maintenance branch, excluding lower than branch start range', t => { const result = getReleaseToAdd({ branch: { name: '2.x', @@ -188,7 +188,7 @@ test('Ignore pre-release versions', t => { }); }); -test('Exclude versions merged from release to maintenance branch if they have the same "channel"', t => { +test('Exclude versions merged = require(release to maintenance branch if they have the same "channel"', t => { const result = getReleaseToAdd({ branch: { name: '2.x', diff --git a/test/git.test.js b/test/git.test.js index 08a11107f9..3454f956a1 100644 --- a/test/git.test.js +++ b/test/git.test.js @@ -1,6 +1,6 @@ -import test from 'ava'; -import tempy from 'tempy'; -import { +const test = require('ava'); +const tempy = require('tempy'); +const { getTagHead, isRefExists, fetch, @@ -16,8 +16,8 @@ import { getNote, addNote, fetchNotes, -} from '../lib/git'; -import { +} = require('../lib/git'); +const { gitRepo, gitCommits, gitCheckout, @@ -34,7 +34,7 @@ import { gitGetNote, gitFetch, initGit, -} from './helpers/git-utils'; +} = require('./helpers/git-utils'); test('Get the last commit sha', async t => { // Create a git repository, set the current working directory at the root of the repo @@ -51,7 +51,7 @@ test('Throw error if the last commit sha cannot be found', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); - await t.throwsAsync(getGitHead({cwd}), Error); + await t.throwsAsync(getGitHead({cwd})); }); test('Unshallow and fetch repository', async t => { diff --git a/test/helpers/git-utils.js b/test/helpers/git-utils.js index e38672fd40..cfe47dc438 100644 --- a/test/helpers/git-utils.js +++ b/test/helpers/git-utils.js @@ -1,10 +1,10 @@ -import tempy from 'tempy'; -import execa from 'execa'; -import fileUrl from 'file-url'; -import pEachSeries from 'p-each-series'; -import gitLogParser from 'git-log-parser'; -import getStream from 'get-stream'; -import {GIT_NOTE_REF} from '../../lib/definitions/constants'; +const tempy = require('tempy'); +const execa = require('execa'); +const fileUrl = require('file-url'); +const pEachSeries = require('p-each-series'); +const gitLogParser = require('git-log-parser'); +const getStream = require('get-stream'); +const {GIT_NOTE_REF} = require('../../lib/definitions/constants'); /** * Commit message information. @@ -23,7 +23,7 @@ import {GIT_NOTE_REF} from '../../lib/definitions/constants'; * @param {Boolean} withRemote `true` to create a shallow clone of a bare repository. * @return {String} The path of the repository */ -export async function initGit(withRemote) { +async function initGit(withRemote) { const cwd = tempy.directory(); await execa('git', ['init', ...(withRemote ? ['--bare'] : [])], {cwd}); @@ -41,7 +41,7 @@ export async function initGit(withRemote) { * @param {String} [branch='master'] The branch to initialize. * @return {String} The path of the clone if `withRemote` is `true`, the path of the repository otherwise. */ -export async function gitRepo(withRemote, branch = 'master') { +async function gitRepo(withRemote, branch = 'master') { let {cwd, repositoryUrl} = await initGit(withRemote); if (withRemote) { await initBareRepo(repositoryUrl, branch); @@ -66,7 +66,7 @@ export async function gitRepo(withRemote, branch = 'master') { * @param {String} repositoryUrl The URL of the bare repository. * @param {String} [branch='master'] the branch to initialize. */ -export async function initBareRepo(repositoryUrl, branch = 'master') { +async function initBareRepo(repositoryUrl, branch = 'master') { const cwd = tempy.directory(); await execa('git', ['clone', '--no-hardlinks', repositoryUrl, cwd], {cwd}); await gitCheckout(branch, true, {cwd}); @@ -82,7 +82,7 @@ export async function initBareRepo(repositoryUrl, branch = 'master') { * * @returns {Array} The created commits, in reverse order (to match `git log` order). */ -export async function gitCommits(messages, execaOpts) { +async function gitCommits(messages, execaOpts) { await pEachSeries( messages, async message => (await execa('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOpts)).stdout @@ -98,7 +98,7 @@ export async function gitCommits(messages, execaOpts) { * * @return {Array} The list of parsed commits. */ -export async function gitGetCommits(from, execaOpts) { +async function gitGetCommits(from, execaOpts) { Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', committerDate: {key: 'ci', type: Date}}); return ( await getStream.array( @@ -118,7 +118,7 @@ export async function gitGetCommits(from, execaOpts) { * @param {Boolean} create to create the branch, `false` to checkout an existing branch. * @param {Object} [execaOpts] Options to pass to `execa`. */ -export async function gitCheckout(branch, create, execaOpts) { +async function gitCheckout(branch, create, execaOpts) { await execa('git', create ? ['checkout', '-b', branch] : ['checkout', branch], execaOpts); } @@ -128,7 +128,7 @@ export async function gitCheckout(branch, create, execaOpts) { * @param {String} repositoryUrl The repository remote URL. * @param {Object} [execaOpts] Options to pass to `execa`. */ -export async function gitFetch(repositoryUrl, execaOpts) { +async function gitFetch(repositoryUrl, execaOpts) { await execa('git', ['fetch', repositoryUrl], execaOpts); } @@ -139,7 +139,7 @@ export async function gitFetch(repositoryUrl, execaOpts) { * * @return {String} The sha of the head commit in the current git repository. */ -export async function gitHead(execaOpts) { +async function gitHead(execaOpts) { return (await execa('git', ['rev-parse', 'HEAD'], execaOpts)).stdout; } @@ -150,7 +150,7 @@ export async function gitHead(execaOpts) { * @param {String} [sha] The commit on which to create the tag. If undefined the tag is created on the last commit. * @param {Object} [execaOpts] Options to pass to `execa`. */ -export async function gitTagVersion(tagName, sha, execaOpts) { +async function gitTagVersion(tagName, sha, execaOpts) { await execa('git', sha ? ['tag', '-f', tagName, sha] : ['tag', tagName], execaOpts); } @@ -163,7 +163,7 @@ export async function gitTagVersion(tagName, sha, execaOpts) { * @param {Number} [depth=1] The number of commit to clone. * @return {String} The path of the cloned repository. */ -export async function gitShallowClone(repositoryUrl, branch = 'master', depth = 1) { +async function gitShallowClone(repositoryUrl, branch = 'master', depth = 1) { const cwd = tempy.directory(); await execa('git', ['clone', '--no-hardlinks', '--no-tags', '-b', branch, '--depth', depth, repositoryUrl, cwd], { @@ -179,7 +179,7 @@ export async function gitShallowClone(repositoryUrl, branch = 'master', depth = * @param {Number} head A commit sha of the remote repo that will become the detached head of the new one. * @return {String} The path of the new repository. */ -export async function gitDetachedHead(repositoryUrl, head) { +async function gitDetachedHead(repositoryUrl, head) { const cwd = tempy.directory(); await execa('git', ['init'], {cwd}); @@ -189,7 +189,7 @@ export async function gitDetachedHead(repositoryUrl, head) { return cwd; } -export async function gitDetachedHeadFromBranch(repositoryUrl, branch, head) { +async function gitDetachedHeadFromBranch(repositoryUrl, branch, head) { const cwd = tempy.directory(); await execa('git', ['init'], {cwd}); @@ -207,7 +207,7 @@ export async function gitDetachedHeadFromBranch(repositoryUrl, branch, head) { * @param {String} value Config value. * @param {Object} [execaOpts] Options to pass to `execa`. */ -export async function gitAddConfig(name, value, execaOpts) { +async function gitAddConfig(name, value, execaOpts) { await execa('git', ['config', '--add', name, value], execaOpts); } @@ -219,7 +219,7 @@ export async function gitAddConfig(name, value, execaOpts) { * * @return {String} The sha of the commit associated with `tagName` on the local repository. */ -export async function gitTagHead(tagName, execaOpts) { +async function gitTagHead(tagName, execaOpts) { return (await execa('git', ['rev-list', '-1', tagName], execaOpts)).stdout; } @@ -232,7 +232,7 @@ export async function gitTagHead(tagName, execaOpts) { * * @return {String} The sha of the commit associated with `tagName` on the remote repository. */ -export async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) { +async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) { return (await execa('git', ['ls-remote', '--tags', repositoryUrl, tagName], execaOpts)).stdout .split('\n') .filter(tag => Boolean(tag)) @@ -247,7 +247,7 @@ export async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) { * * @return {String} The tag associatedwith the sha in parameter or `null`. */ -export async function gitCommitTag(gitHead, execaOpts) { +async function gitCommitTag(gitHead, execaOpts) { return (await execa('git', ['describe', '--tags', '--exact-match', gitHead], execaOpts)).stdout; } @@ -260,7 +260,7 @@ export async function gitCommitTag(gitHead, execaOpts) { * * @throws {Error} if the push failed. */ -export async function gitPush(repositoryUrl, branch, execaOpts) { +async function gitPush(repositoryUrl, branch, execaOpts) { await execa('git', ['push', '--tags', repositoryUrl, `HEAD:${branch}`], execaOpts); } @@ -270,7 +270,7 @@ export async function gitPush(repositoryUrl, branch, execaOpts) { * @param {String} ref The ref to merge. * @param {Object} [execaOpts] Options to pass to `execa`. */ -export async function merge(ref, execaOpts) { +async function merge(ref, execaOpts) { await execa('git', ['merge', '--no-ff', ref], execaOpts); } @@ -280,7 +280,7 @@ export async function merge(ref, execaOpts) { * @param {String} ref The ref to merge. * @param {Object} [execaOpts] Options to pass to `execa`. */ -export async function mergeFf(ref, execaOpts) { +async function mergeFf(ref, execaOpts) { await execa('git', ['merge', '--ff', ref], execaOpts); } @@ -290,7 +290,7 @@ export async function mergeFf(ref, execaOpts) { * @param {String} ref The ref to merge. * @param {Object} [execaOpts] Options to pass to `execa`. */ -export async function rebase(ref, execaOpts) { +async function rebase(ref, execaOpts) { await execa('git', ['rebase', ref], execaOpts); } @@ -301,7 +301,7 @@ export async function rebase(ref, execaOpts) { * @param {String} ref The ref to add the note to. * @param {Object} [execaOpts] Options to pass to `execa`. */ -export async function gitAddNote(note, ref, execaOpts) { +async function gitAddNote(note, ref, execaOpts) { await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'add', '-m', note, ref], execaOpts); } @@ -311,6 +311,31 @@ export async function gitAddNote(note, ref, execaOpts) { * @param {String} ref The ref to get the note from. * @param {Object} [execaOpts] Options to pass to `execa`. */ -export async function gitGetNote(ref, execaOpts) { +async function gitGetNote(ref, execaOpts) { return (await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'show', ref], execaOpts)).stdout; } + +module.exports = { + initGit, + gitRepo, + initBareRepo, + gitCommits, + gitGetCommits, + gitCheckout, + gitFetch, + gitHead, + gitTagVersion, + gitShallowClone, + gitDetachedHead, + gitDetachedHeadFromBranch, + gitAddConfig, + gitTagHead, + gitRemoteTagHead, + gitCommitTag, + gitPush, + merge, + mergeFf, + rebase, + gitAddNote, + gitGetNote, +}; diff --git a/test/helpers/gitbox.js b/test/helpers/gitbox.js index 6ddd586fb7..cae7c44ac9 100644 --- a/test/helpers/gitbox.js +++ b/test/helpers/gitbox.js @@ -1,7 +1,7 @@ -import Docker from 'dockerode'; -import getStream from 'get-stream'; -import pRetry from 'p-retry'; -import {initBareRepo, gitShallowClone} from './git-utils'; +const Docker = require('dockerode'); +const getStream = require('get-stream'); +const pRetry = require('p-retry'); +const {initBareRepo, gitShallowClone} = require('./git-utils'); const IMAGE = 'pvdlg/docker-gitbox:latest'; const SERVER_PORT = 80; @@ -69,4 +69,4 @@ async function createRepo(name, branch = 'master', description = `Repository ${n return {cwd, repositoryUrl, authUrl}; } -export default {start, stop, gitCredential, createRepo}; +module.exports = {start, stop, gitCredential, createRepo}; diff --git a/test/helpers/mockserver.js b/test/helpers/mockserver.js index 72ee155f9b..51db154525 100644 --- a/test/helpers/mockserver.js +++ b/test/helpers/mockserver.js @@ -1,8 +1,8 @@ -import Docker from 'dockerode'; -import getStream from 'get-stream'; -import got from 'got'; -import pRetry from 'p-retry'; -import {mockServerClient} from 'mockserver-client'; +const Docker = require('dockerode'); +const getStream = require('get-stream'); +const got = require('got'); +const pRetry = require('p-retry'); +const {mockServerClient} = require('mockserver-client'); const IMAGE = 'jamesdbloom/mockserver:latest'; const MOCK_SERVER_PORT = 1080; @@ -100,4 +100,4 @@ function verify(expectation) { return client.verify(expectation); } -export default {start, stop, mock, verify, url}; +module.exports = {start, stop, mock, verify, url}; diff --git a/test/helpers/npm-registry.js b/test/helpers/npm-registry.js index c646dabd0a..e41bc1f8ce 100644 --- a/test/helpers/npm-registry.js +++ b/test/helpers/npm-registry.js @@ -1,8 +1,8 @@ -import Docker from 'dockerode'; -import getStream from 'get-stream'; -import got from 'got'; -import delay from 'delay'; -import pRetry from 'p-retry'; +const Docker = require('dockerode'); +const getStream = require('get-stream'); +const got = require('got'); +const delay = require('delay'); +const pRetry = require('p-retry'); const IMAGE = 'semanticrelease/npm-registry-docker:latest'; const SERVER_PORT = 15986; @@ -76,4 +76,4 @@ async function stop() { await container.remove(); } -export default {start, stop, authEnv, url}; +module.exports = {start, stop, authEnv, url}; diff --git a/test/helpers/npm-utils.js b/test/helpers/npm-utils.js index ea0192a85d..942a31ead4 100644 --- a/test/helpers/npm-utils.js +++ b/test/helpers/npm-utils.js @@ -1,5 +1,7 @@ -import execa from 'execa'; +const execa = require('execa'); -export async function npmView(packageName, env) { +async function npmView(packageName, env) { return JSON.parse((await execa('npm', ['view', packageName, '--json'], {env})).stdout); } + +module.exports = {npmView}; diff --git a/test/hide-sensitive.test.js b/test/hide-sensitive.test.js index 0d28a27428..e6d456a688 100644 --- a/test/hide-sensitive.test.js +++ b/test/hide-sensitive.test.js @@ -1,7 +1,7 @@ -import test from 'ava'; -import {repeat} from 'lodash'; -import hideSensitive from '../lib/hide-sensitive'; -import {SECRET_REPLACEMENT, SECRET_MIN_SIZE} from '../lib/definitions/constants'; +const test = require('ava'); +const {repeat} = require('lodash'); +const hideSensitive = require('../lib/hide-sensitive'); +const {SECRET_REPLACEMENT, SECRET_MIN_SIZE} = require('../lib/definitions/constants'); test('Replace multiple sensitive environment variable values', t => { const env = {SOME_PASSWORD: 'password', SOME_TOKEN: 'secret'}; diff --git a/test/index.test.js b/test/index.test.js index 08f8075bd1..65a30bd284 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -1,13 +1,13 @@ -import test from 'ava'; -import {escapeRegExp, isString, sortBy, omit} from 'lodash'; -import proxyquire from 'proxyquire'; -import {spy, stub} from 'sinon'; -import {WritableStreamBuffer} from 'stream-buffers'; -import AggregateError from 'aggregate-error'; -import SemanticReleaseError from '@semantic-release/error'; -import {COMMIT_NAME, COMMIT_EMAIL, SECRET_REPLACEMENT} from '../lib/definitions/constants'; -import { - gitHead as getGitHead, +const test = require('ava'); +const {escapeRegExp, isString, sortBy, omit} = require('lodash'); +const proxyquire = require('proxyquire'); +const {spy, stub} = require('sinon'); +const {WritableStreamBuffer} = require('stream-buffers'); +const AggregateError = require('aggregate-error'); +const SemanticReleaseError = require('@semantic-release/error'); +const {COMMIT_NAME, COMMIT_EMAIL, SECRET_REPLACEMENT} = require('../lib/definitions/constants'); +const { + gitHead: getGitHead, gitCheckout, gitTagHead, gitRepo, @@ -21,7 +21,7 @@ import { rebase, gitAddNote, gitGetNote, -} from './helpers/git-utils'; +} = require('./helpers/git-utils'); const requireNoCache = proxyquire.noPreserveCache(); const pluginNoop = require.resolve('./fixtures/plugin-noop'); @@ -1807,7 +1807,7 @@ test('Throw an Error if plugin returns an unexpected value', async t => { }); const error = await t.throwsAsync( semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}), - Error + {instanceOf: SemanticReleaseError} ); t.regex(error.details, /string/); }); @@ -1836,8 +1836,7 @@ test('Hide sensitive information passed to "fail" plugin', async t => { 'env-ci': () => ({isCi: true, branch: 'master', isPr: false}), }); await t.throwsAsync( - semanticRelease(options, {cwd, env, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}), - Error + semanticRelease(options, {cwd, env, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}) ); const error = fail.args[0][1].errors[0]; diff --git a/test/integration.test.js b/test/integration.test.js index 8840a1888e..9c92d29c9b 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -1,13 +1,13 @@ -import path from 'path'; -import proxyquire from 'proxyquire'; -import test from 'ava'; -import {escapeRegExp} from 'lodash'; -import {writeJson, readJson} from 'fs-extra'; -import execa from 'execa'; -import {WritableStreamBuffer} from 'stream-buffers'; -import delay from 'delay'; -import {SECRET_REPLACEMENT} from '../lib/definitions/constants'; -import { +const path = require('path'); +const test = require('ava'); +const proxyquire = require('proxyquire'); +const {escapeRegExp} = require('lodash'); +const {writeJson, readJson} = require('fs-extra'); +const execa = require('execa'); +const {WritableStreamBuffer} = require('stream-buffers'); +const delay = require('delay'); +const {SECRET_REPLACEMENT} = require('../lib/definitions/constants'); +const { gitHead, gitTagHead, gitRepo, @@ -17,11 +17,11 @@ import { gitCheckout, merge, gitGetNote, -} from './helpers/git-utils'; -import {npmView} from './helpers/npm-utils'; -import gitbox from './helpers/gitbox'; -import mockServer from './helpers/mockserver'; -import npmRegistry from './helpers/npm-registry'; +} = require('./helpers/git-utils'); +const {npmView} = require('./helpers/npm-utils'); +const gitbox = require('./helpers/gitbox'); +const mockServer = require('./helpers/mockserver'); +const npmRegistry = require('./helpers/npm-registry'); /* eslint camelcase: ["error", {properties: "never"}] */ diff --git a/test/plugins/normalize.test.js b/test/plugins/normalize.test.js index dd93467ed5..4646a6baf5 100644 --- a/test/plugins/normalize.test.js +++ b/test/plugins/normalize.test.js @@ -1,7 +1,7 @@ -import test from 'ava'; -import {noop} from 'lodash'; -import {stub} from 'sinon'; -import normalize from '../../lib/plugins/normalize'; +const test = require('ava'); +const {noop} = require('lodash'); +const {stub} = require('sinon'); +const normalize = require('../../lib/plugins/normalize'); const cwd = process.cwd(); @@ -268,11 +268,9 @@ test('Throws an error if the plugin return an object without the expected plugin }); test('Throws an error if the plugin is not found', t => { - const error = t.throws( - () => normalize({cwd, options: {}, logger: t.context.logger}, 'inexistantPlugin', 'non-existing-path', {}), - Error - ); - - t.regex(error.message, /Cannot find module 'non-existing-path'/); - t.is(error.code, 'MODULE_NOT_FOUND'); + t.throws(() => normalize({cwd, options: {}, logger: t.context.logger}, 'inexistantPlugin', 'non-existing-path', {}), { + message: /Cannot find module 'non-existing-path'/, + code: 'MODULE_NOT_FOUND', + instanceOf: Error, + }); }); diff --git a/test/plugins/pipeline.test.js b/test/plugins/pipeline.test.js index d3f6e43431..5100b5bf84 100644 --- a/test/plugins/pipeline.test.js +++ b/test/plugins/pipeline.test.js @@ -1,7 +1,7 @@ -import test from 'ava'; -import {stub} from 'sinon'; -import AggregateError from 'aggregate-error'; -import pipeline from '../../lib/plugins/pipeline'; +const test = require('ava'); +const {stub} = require('sinon'); +const AggregateError = require('aggregate-error'); +const pipeline = require('../../lib/plugins/pipeline'); test('Execute each function in series passing the same input', async t => { const step1 = stub().resolves(1); @@ -98,7 +98,10 @@ test('Stop execution and throw error if a step rejects', async t => { const step2 = stub().rejects(new Error('test error')); const step3 = stub().resolves(3); - const error = await t.throwsAsync(pipeline([step1, step2, step3])(0), Error); + const error = await t.throwsAsync(pipeline([step1, step2, step3])(0), { + instanceOf: Error, + message: 'test error', + }); t.is(error.message, 'test error'); t.true(step1.calledWith(0)); t.true(step2.calledWith(0)); diff --git a/test/plugins/plugins.test.js b/test/plugins/plugins.test.js index bdfa07bcf3..97a83b27f0 100644 --- a/test/plugins/plugins.test.js +++ b/test/plugins/plugins.test.js @@ -1,9 +1,9 @@ -import path from 'path'; -import test from 'ava'; -import {copy, outputFile} from 'fs-extra'; -import {stub} from 'sinon'; -import tempy from 'tempy'; -import getPlugins from '../../lib/plugins'; +const path = require('path'); +const test = require('ava'); +const {copy, outputFile} = require('fs-extra'); +const {stub} = require('sinon'); +const tempy = require('tempy'); +const getPlugins = require('../../lib/plugins'); // Save the current working diretory const cwd = process.cwd(); diff --git a/test/plugins/utils.test.js b/test/plugins/utils.test.js index e781316c9c..eadbe7a476 100644 --- a/test/plugins/utils.test.js +++ b/test/plugins/utils.test.js @@ -1,5 +1,5 @@ -import test from 'ava'; -import {validatePlugin, validateStep, loadPlugin, parseConfig} from '../../lib/plugins/utils'; +const test = require('ava'); +const {validatePlugin, validateStep, loadPlugin, parseConfig} = require('../../lib/plugins/utils'); test('validatePlugin', t => { const path = 'plugin-module'; diff --git a/test/utils.test.js b/test/utils.test.js index dd05a04907..b3d4ae3dd1 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -1,6 +1,6 @@ -import test from 'ava'; -import AggregateError from 'aggregate-error'; -import { +const test = require('ava'); +const AggregateError = require('aggregate-error'); +const { extractErrors, tagsToVersions, isMajorRange, @@ -15,7 +15,7 @@ import { getRange, makeTag, isSameChannel, -} from '../lib/utils'; +} = require('../lib/utils'); test('extractErrors', t => { const errors = [new Error('Error 1'), new Error('Error 2')]; diff --git a/test/verify.test.js b/test/verify.test.js index 09d882850d..765b655e74 100644 --- a/test/verify.test.js +++ b/test/verify.test.js @@ -1,7 +1,7 @@ -import test from 'ava'; -import tempy from 'tempy'; -import verify from '../lib/verify'; -import {gitRepo} from './helpers/git-utils'; +const test = require('ava'); +const tempy = require('tempy'); +const verify = require('../lib/verify'); +const {gitRepo} = require('./helpers/git-utils'); test('Throw a AggregateError', async t => { const {cwd} = await gitRepo();