diff --git a/package.json b/package.json index b1d9f7a4..4c2a2242 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "yargs": "^12.0.0" }, "devDependencies": { - "ava": "^0.25.0", + "ava": "^1.0.1", "clear-module": "^3.0.0", "codecov": "^3.0.0", "commitizen": "^3.0.0", diff --git a/test/branches/branches.test.js b/test/branches/branches.test.js index a8f4c3cb..0bddf703 100644 --- a/test/branches/branches.test.js +++ b/test/branches/branches.test.js @@ -146,7 +146,7 @@ test('Throw SemanticReleaseError for invalid configurations', async t => { {name: 'preview', prerelease: 'alpha', tags: []}, ]; const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []}); - const errors = [...(await t.throws(getBranches({options: {branches}})))]; + const errors = [...(await t.throwsAsync(getBranches({options: {branches}})))]; t.is(errors[0].name, 'SemanticReleaseError'); t.is(errors[0].code, 'EMAINTENANCEBRANCH'); @@ -174,7 +174,7 @@ test('Throw a SemanticReleaseError if there is duplicate branches', async t => { const branches = [{name: 'master', tags: []}, {name: 'master', tags: []}]; const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []}); - const errors = [...(await t.throws(getBranches({options: {branches}})))]; + const errors = [...(await t.throwsAsync(getBranches({options: {branches}})))]; t.is(errors[0].name, 'SemanticReleaseError'); t.is(errors[0].code, 'EDUPLICATEBRANCHES'); @@ -186,7 +186,7 @@ test('Throw a SemanticReleaseError for each invalid branch name', async t => { const branches = [{name: '~master', tags: []}, {name: '^master', tags: []}]; const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []}); - const errors = [...(await t.throws(getBranches({options: {branches}})))]; + const errors = [...(await t.throwsAsync(getBranches({options: {branches}})))]; t.is(errors[0].name, 'SemanticReleaseError'); t.is(errors[0].code, 'EINVALIDBRANCHNAME'); diff --git a/test/get-config.test.js b/test/get-config.test.js index 1df49e60..32866464 100644 --- a/test/get-config.test.js +++ b/test/get-config.test.js @@ -511,7 +511,7 @@ 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.throws(t.context.getConfig({cwd}), Error); + const error = await t.throwsAsync(t.context.getConfig({cwd}), Error); t.is(error.message, "Cannot find module 'non-existing-path'"); t.is(error.code, 'MODULE_NOT_FOUND'); diff --git a/test/git.test.js b/test/git.test.js index c0ab6e97..37e48b80 100644 --- a/test/git.test.js +++ b/test/git.test.js @@ -44,7 +44,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.throws(getGitHead({cwd}), Error); + await t.throwsAsync(getGitHead({cwd}), Error); }); test('Unshallow and fetch repository', async t => { @@ -73,8 +73,8 @@ test('Do not throw error when unshallow a complete repository', async t => { await gitCommits(['Second'], {cwd}); await gitPush(repositoryUrl, 'second-branch', {cwd}); - await t.notThrows(fetch('master', {cwd})); - await t.notThrows(fetch('second-branch', {cwd})); + await t.notThrowsAsync(fetch('master', {cwd})); + await t.notThrowsAsync(fetch('second-branch', {cwd})); }); test('Fetch all tags on a detached head repository', async t => { @@ -108,7 +108,7 @@ test('Verify if the commit `sha` is in the direct history of the current branch' t.true(await isRefInHistory(commits[0].hash, 'master', false, {cwd})); t.falsy(await isRefInHistory(otherCommits[0].hash, 'master', false, {cwd})); t.falsy(await isRefInHistory(otherCommits[0].hash, 'missing-branch', false, {cwd})); - await t.throws(isRefInHistory('non-existant-sha', 'master', false, {cwd})); + await t.throwsAsync(isRefInHistory('non-existant-sha', 'master', false, {cwd})); }); test('Verify if a branch exists', async t => { @@ -243,7 +243,7 @@ test('Return falsy for invalid tag names', async t => { test('Throws error if obtaining the tags fails', async t => { const cwd = tempy.directory(); - await t.throws(getTags({cwd})); + await t.throwsAsync(getTags({cwd})); }); test('Return "true" if repository is up to date', async t => { diff --git a/test/index.test.js b/test/index.test.js index 6984331e..e00bc7f6 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -763,7 +763,7 @@ test('Call all "success" plugins even if one errors out', async t => { 'env-ci': () => ({isCi: true, branch: 'master', isPr: false}), }); - await t.throws( + await t.throwsAsync( semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}) ); @@ -799,7 +799,7 @@ test('Log all "verifyConditions" errors', async t => { 'env-ci': () => ({isCi: true, branch: 'master', isPr: false}), }); const errors = [ - ...(await t.throws( + ...(await t.throwsAsync( semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}) )), ]; @@ -844,7 +844,7 @@ test('Log all "verifyRelease" errors', async t => { 'env-ci': () => ({isCi: true, branch: 'master', isPr: false}), }); const errors = [ - ...(await t.throws( + ...(await t.throwsAsync( semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}) )), ]; @@ -949,7 +949,7 @@ test('Dry-run skips fail', async t => { 'env-ci': () => ({isCi: true, branch: 'master', isPr: false}), }); const errors = [ - ...(await t.throws( + ...(await t.throwsAsync( semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}) )), ]; @@ -1268,7 +1268,7 @@ test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the curren 'env-ci': () => ({isCi: true, branch: '1.x', isPr: false}), }); - const error = await t.throws( + const error = await t.throwsAsync( semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}}) ); @@ -1319,7 +1319,7 @@ test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the curren 'env-ci': () => ({isCi: true, branch: 'master', isPr: false}), }); - const error = await t.throws( + const error = await t.throwsAsync( semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}}) ); @@ -1388,7 +1388,9 @@ test('Throws "EINVALIDMAINTENANCEMERGE" if merge an out of range release in a ma 'env-ci': () => ({isCi: true, branch: '1.1.x', isPr: false}), }); const errors = [ - ...(await t.throws(semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}}))), + ...(await t.throwsAsync( + semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}}) + )), ]; t.is(addChannel.callCount, 1); @@ -1587,7 +1589,7 @@ test('Log both plugins errors and errors thrown by "fail" plugin', async t => { 'env-ci': () => ({isCi: true, branch: 'master', isPr: false}), }); - await t.throws( + await t.throwsAsync( semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}) ); @@ -1612,7 +1614,7 @@ test('Call "fail" only if a plugin returns a SemanticReleaseError', async t => { 'env-ci': () => ({isCi: true, branch: 'master', isPr: false}), }); - await t.throws( + await t.throwsAsync( semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}) ); @@ -1629,7 +1631,7 @@ test('Throw SemanticReleaseError if repositoryUrl is not set and cannot be found 'env-ci': () => ({isCi: true, branch: 'master', isPr: false}), }); const errors = [ - ...(await t.throws( + ...(await t.throwsAsync( semanticRelease({}, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}) )), ]; @@ -1668,7 +1670,7 @@ test('Throw an Error if plugin returns an unexpected value', async t => { './lib/get-logger': () => t.context.logger, 'env-ci': () => ({isCi: true, branch: 'master', isPr: false}), }); - const error = await t.throws( + const error = await t.throwsAsync( semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}), Error ); @@ -1698,7 +1700,7 @@ test('Hide sensitive information passed to "fail" plugin', async t => { './lib/get-logger': () => t.context.logger, 'env-ci': () => ({isCi: true, branch: 'master', isPr: false}), }); - await t.throws( + await t.throwsAsync( semanticRelease(options, {cwd, env, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}), Error ); diff --git a/test/integration.test.js b/test/integration.test.js index 485bd740..ee61a8ea 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -317,7 +317,7 @@ test('Exit with 1 if a plugin is not found', async t => { release: {analyzeCommits: 'non-existing-path', success: false, fail: false}, }); - const {code, stderr} = await t.throws(execa(cli, [], {env, cwd})); + const {code, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd})); t.is(code, 1); t.regex(stderr, /Cannot find module/); }); @@ -335,7 +335,7 @@ test('Exit with 1 if a shareable config is not found', async t => { release: {extends: 'non-existing-path', success: false, fail: false}, }); - const {code, stderr} = await t.throws(execa(cli, [], {env, cwd})); + const {code, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd})); t.is(code, 1); t.regex(stderr, /Cannot find module/); }); @@ -356,7 +356,7 @@ test('Exit with 1 if a shareable config reference a not found plugin', async t = }); await writeJson(path.resolve(cwd, 'shareable.json'), shareable); - const {code, stderr} = await t.throws(execa(cli, [], {env, cwd})); + const {code, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd})); t.is(code, 1); t.regex(stderr, /Cannot find module/); }); diff --git a/test/plugins/normalize.test.js b/test/plugins/normalize.test.js index 8965af89..9c5f2125 100644 --- a/test/plugins/normalize.test.js +++ b/test/plugins/normalize.test.js @@ -62,7 +62,7 @@ test('Wrap plugin in a function that add the "pluginName" to the error"', async './plugin-error': './test/fixtures', }); - const error = await t.throws(plugin({options: {}})); + const error = await t.throwsAsync(plugin({options: {}})); t.is(error.pluginName, './plugin-error'); }); @@ -72,7 +72,7 @@ test('Wrap plugin in a function that add the "pluginName" to multiple errors"', './plugin-errors': './test/fixtures', }); - const errors = [...(await t.throws(plugin({options: {}})))]; + const errors = [...(await t.throwsAsync(plugin({options: {}})))]; for (const error of errors) { t.is(error.pluginName, './plugin-errors'); } @@ -107,7 +107,7 @@ test('Wrap "analyzeCommits" plugin in a function that validate the output of the {} ); - const error = await t.throws(plugin({options: {}})); + const error = await t.throwsAsync(plugin({options: {}})); t.is(error.code, 'EANALYZECOMMITSOUTPUT'); t.is(error.name, 'SemanticReleaseError'); @@ -125,7 +125,7 @@ test('Wrap "generateNotes" plugin in a function that validate the output of the {} ); - const error = await t.throws(plugin({options: {}})); + const error = await t.throwsAsync(plugin({options: {}})); t.is(error.code, 'EGENERATENOTESOUTPUT'); t.is(error.name, 'SemanticReleaseError'); @@ -143,7 +143,7 @@ test('Wrap "publish" plugin in a function that validate the output of the plugin {} ); - const error = await t.throws(plugin({options: {}})); + const error = await t.throwsAsync(plugin({options: {}})); t.is(error.code, 'EPUBLISHOUTPUT'); t.is(error.name, 'SemanticReleaseError'); @@ -161,7 +161,7 @@ test('Wrap "addChannel" plugin in a function that validate the output of the plu {} ); - const error = await t.throws(plugin({options: {}})); + const error = await t.throwsAsync(plugin({options: {}})); t.is(error.code, 'EADDCHANNELOUTPUT'); t.is(error.name, 'SemanticReleaseError'); diff --git a/test/plugins/pipeline.test.js b/test/plugins/pipeline.test.js index 2a673941..6c58129e 100644 --- a/test/plugins/pipeline.test.js +++ b/test/plugins/pipeline.test.js @@ -83,7 +83,7 @@ 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.throws(pipeline([step1, step2, step3])(0), Error); + const error = await t.throwsAsync(pipeline([step1, step2, step3])(0), Error); t.is(error.message, 'test error'); t.true(step1.calledWith(0)); t.true(step2.calledWith(0)); @@ -98,7 +98,7 @@ test('Throw all errors from the first step throwing an AggregateError', async t const step2 = stub().rejects(new AggregateError([error1, error2])); const step3 = stub().resolves(3); - const errors = await t.throws(pipeline([step1, step2, step3])(0)); + const errors = await t.throwsAsync(pipeline([step1, step2, step3])(0)); t.deepEqual([...errors], [error1, error2]); t.true(step1.calledWith(0)); @@ -113,7 +113,7 @@ test('Execute all even if a Promise rejects', async t => { const step2 = stub().rejects(error1); const step3 = stub().rejects(error2); - const errors = await t.throws(pipeline([step1, step2, step3], {settleAll: true})(0)); + const errors = await t.throwsAsync(pipeline([step1, step2, step3], {settleAll: true})(0)); t.deepEqual([...errors], [error1, error2]); t.true(step1.calledWith(0)); @@ -129,7 +129,7 @@ test('Throw all errors from all steps throwing an AggregateError', async t => { const step1 = stub().rejects(new AggregateError([error1, error2])); const step2 = stub().rejects(new AggregateError([error3, error4])); - const errors = await t.throws(pipeline([step1, step2], {settleAll: true})(0)); + const errors = await t.throwsAsync(pipeline([step1, step2], {settleAll: true})(0)); t.deepEqual([...errors], [error1, error2, error3, error4]); t.true(step1.calledWith(0)); @@ -145,7 +145,7 @@ test('Execute each function in series passing a transformed input even if a step const step4 = stub().resolves(4); const getNextInput = (prevResult, result) => prevResult + result; - const errors = await t.throws(pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput})(0)); + const errors = await t.throwsAsync(pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput})(0)); t.deepEqual([...errors], [error2, error3]); t.true(step1.calledWith(0)); diff --git a/test/verify.test.js b/test/verify.test.js index dba1818b..09d88285 100644 --- a/test/verify.test.js +++ b/test/verify.test.js @@ -7,7 +7,7 @@ test('Throw a AggregateError', async t => { const {cwd} = await gitRepo(); const options = {branches: [{name: 'master'}, {name: ''}]}; - const errors = [...(await t.throws(verify({cwd, options})))]; + const errors = [...(await t.throwsAsync(verify({cwd, options})))]; t.is(errors[0].name, 'SemanticReleaseError'); t.is(errors[0].code, 'ENOREPOURL'); @@ -31,7 +31,7 @@ test('Throw a SemanticReleaseError if does not run on a git repository', async t const cwd = tempy.directory(); const options = {branches: []}; - const errors = [...(await t.throws(verify({cwd, options})))]; + const errors = [...(await t.throwsAsync(verify({cwd, options})))]; t.is(errors[0].name, 'SemanticReleaseError'); t.is(errors[0].code, 'ENOGITREPO'); @@ -43,7 +43,7 @@ test('Throw a SemanticReleaseError if the "tagFormat" is not valid', async t => const {cwd, repositoryUrl} = await gitRepo(true); const options = {repositoryUrl, tagFormat: `?\${version}`, branches: []}; - const errors = [...(await t.throws(verify({cwd, options})))]; + const errors = [...(await t.throwsAsync(verify({cwd, options})))]; t.is(errors[0].name, 'SemanticReleaseError'); t.is(errors[0].code, 'EINVALIDTAGFORMAT'); @@ -55,7 +55,7 @@ test('Throw a SemanticReleaseError if the "tagFormat" does not contains the "ver const {cwd, repositoryUrl} = await gitRepo(true); const options = {repositoryUrl, tagFormat: 'test', branches: []}; - const errors = [...(await t.throws(verify({cwd, options})))]; + const errors = [...(await t.throwsAsync(verify({cwd, options})))]; t.is(errors[0].name, 'SemanticReleaseError'); t.is(errors[0].code, 'ETAGNOVERSION'); @@ -67,7 +67,7 @@ test('Throw a SemanticReleaseError if the "tagFormat" contains multiple "version const {cwd, repositoryUrl} = await gitRepo(true); const options = {repositoryUrl, tagFormat: `\${version}v\${version}`, branches: []}; - const errors = [...(await t.throws(verify({cwd, options})))]; + const errors = [...(await t.throwsAsync(verify({cwd, options})))]; t.is(errors[0].name, 'SemanticReleaseError'); t.is(errors[0].code, 'ETAGNOVERSION'); @@ -83,7 +83,7 @@ test('Throw a SemanticReleaseError for each invalid branch', async t => { branches: [{name: ''}, {name: ' '}, {name: 1}, {}, {name: ''}, 1, 'master'], }; - const errors = [...(await t.throws(verify({cwd, options})))]; + const errors = [...(await t.throwsAsync(verify({cwd, options})))]; t.is(errors[0].name, 'SemanticReleaseError'); t.is(errors[0].code, 'EINVALIDBRANCH'); @@ -113,5 +113,5 @@ test('Return "true" if all verification pass', async t => { const {cwd, repositoryUrl} = await gitRepo(true); const options = {repositoryUrl, tagFormat: `v\${version}`, branches: [{name: 'master'}]}; - await t.notThrows(verify({cwd, options})); + await t.notThrowsAsync(verify({cwd, options})); });