diff --git a/package.json b/package.json index 91ae20e9..71021329 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,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/get-config.test.js b/test/get-config.test.js index 568b5870..9ea58ec9 100644 --- a/test/get-config.test.js +++ b/test/get-config.test.js @@ -480,7 +480,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 661e4ef4..3ae326a3 100644 --- a/test/git.test.js +++ b/test/git.test.js @@ -42,7 +42,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 => { @@ -67,7 +67,7 @@ test('Do not throw error when unshallow a complete repository', async t => { const {cwd, repositoryUrl} = await gitRepo(); // Add commits to the master branch await gitCommits(['First'], {cwd}); - await t.notThrows(fetch(repositoryUrl, {cwd})); + await t.notThrowsAsync(fetch(repositoryUrl, {cwd})); }); test('Fetch all tags on a detached head repository', async t => { @@ -100,7 +100,7 @@ test('Verify if the commit `sha` is in the direct history of the current branch' t.true(await isRefInHistory(commits[0].hash, {cwd})); t.falsy(await isRefInHistory(otherCommits[0].hash, {cwd})); - await t.throws(isRefInHistory('non-existant-sha', {cwd})); + await t.throwsAsync(isRefInHistory('non-existant-sha', {cwd})); }); test('Get the commit sha for a given tag or falsy if the tag does not exists', async t => { @@ -206,7 +206,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 1242ceb4..b66ed916 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -337,7 +337,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()}) ); @@ -372,7 +372,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()}) )), ]; @@ -417,7 +417,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()}) )), ]; @@ -519,7 +519,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()}) )), ]; @@ -957,7 +957,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()}) ); @@ -982,7 +982,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()}) ); @@ -999,7 +999,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()}) )), ]; @@ -1036,7 +1036,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 ); @@ -1066,7 +1066,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 ecbf704f..e0d8f082 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -258,7 +258,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/); }); @@ -276,7 +276,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/); }); @@ -297,7 +297,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 d42ae479..64dfec8f 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'); 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 3bf1e100..034252d2 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 = {}; - 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'); @@ -27,7 +27,7 @@ test('Throw a SemanticReleaseError if does not run on a git repository', async t const cwd = tempy.directory(); const options = {}; - 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'); @@ -39,7 +39,7 @@ test('Throw a SemanticReleaseError if the "tagFormat" is not valid', async t => const {cwd, repositoryUrl} = await gitRepo(true); const options = {repositoryUrl, tagFormat: `?\${version}`}; - 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'); @@ -51,7 +51,7 @@ test('Throw a SemanticReleaseError if the "tagFormat" does not contains the "ver const {cwd, repositoryUrl} = await gitRepo(true); const options = {repositoryUrl, tagFormat: 'test'}; - 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'); @@ -63,7 +63,7 @@ test('Throw a SemanticReleaseError if the "tagFormat" contains multiple "version const {cwd, repositoryUrl} = await gitRepo(true); const options = {repositoryUrl, tagFormat: `\${version}v\${version}`}; - 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'); @@ -75,5 +75,5 @@ test('Return "true" if all verification pass', async t => { const {cwd, repositoryUrl} = await gitRepo(true); const options = {repositoryUrl, tagFormat: `v\${version}`}; - await t.notThrows(verify({cwd, options})); + await t.notThrowsAsync(verify({cwd, options})); });