diff --git a/test/get-commits.test.js b/test/get-commits.test.js index 3366de46..ad59f60b 100644 --- a/test/get-commits.test.js +++ b/test/get-commits.test.js @@ -1,6 +1,5 @@ import test from 'ava'; import {stub} from 'sinon'; -import SemanticReleaseError from '@semantic-release/error'; import getCommits from '../lib/get-commits'; import { gitRepo, @@ -409,7 +408,7 @@ test.serial('Throws ENOGITHEAD error if the gitHead of the last release cannot b // Verify error code and type t.is(error.code, 'ENOGITHEAD'); - t.true(error instanceof SemanticReleaseError); + t.is(error.name, 'SemanticReleaseError'); // Verify the log function has been called with a message explaining the error t.regex( t.context.error.firstCall.args[0], @@ -428,7 +427,7 @@ test.serial('Throws ENOTINHISTORY error if gitHead is not in history', async t = // Verify error code and type t.is(error.code, 'ENOTINHISTORY'); - t.true(error instanceof SemanticReleaseError); + t.is(error.name, 'SemanticReleaseError'); // Verify the log function has been called with a message mentionning the branch t.regex(t.context.error.firstCall.args[0], /history of the "master" branch/); // Verify the log function has been called with a message mentionning the missing gitHead @@ -453,7 +452,7 @@ test.serial('Throws ENOTINHISTORY error if gitHead is not in branch history but // Verify error code and type t.is(error.code, 'ENOTINHISTORY'); - t.true(error instanceof SemanticReleaseError); + t.is(error.name, 'SemanticReleaseError'); // Verify the log function has been called with a message mentionning the branch t.regex(t.context.error.firstCall.args[0], /history of the "master" branch/); // Verify the log function has been called with a message mentionning the missing gitHead @@ -482,7 +481,7 @@ test.serial('Throws ENOTINHISTORY error if gitHead is not in detached head but p // Verify error code and type t.is(error.code, 'ENOTINHISTORY'); - t.true(error instanceof SemanticReleaseError); + t.is(error.name, 'SemanticReleaseError'); // Verify the log function has been called with a message mentionning the branch t.regex(t.context.error.firstCall.args[0], /history of the "master" branch/); // Verify the log function has been called with a message mentionning the missing gitHead @@ -508,7 +507,7 @@ test.serial('Throws ENOTINHISTORY error when a tag is not in branch history but const error = await t.throws(getCommits({version: '1.0.0'}, 'master', t.context.logger)); // Verify error code and type t.is(error.code, 'ENOTINHISTORY'); - t.true(error instanceof SemanticReleaseError); + t.is(error.name, 'SemanticReleaseError'); // Verify the log function has been called with a message mentionning the branch t.regex(t.context.error.firstCall.args[0], /history of the "master" branch/); // Verify the log function has been called with a message mentionning the missing gitHead diff --git a/test/git.test.js b/test/git.test.js index 24097936..57ae1e53 100644 --- a/test/git.test.js +++ b/test/git.test.js @@ -36,7 +36,7 @@ test.serial('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 await gitRepo(); - await t.throws(gitHead()); + await t.throws(gitHead(), Error); }); test.serial('Unshallow repository', async t => { diff --git a/test/index.test.js b/test/index.test.js index 67b69e4f..54051a5d 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -2,7 +2,6 @@ import test from 'ava'; import proxyquire from 'proxyquire'; import {stub} from 'sinon'; import tempy from 'tempy'; -import SemanticReleaseError from '@semantic-release/error'; import DEFINITIONS from '../lib/plugins/definitions'; import {gitHead as getGitHead} from '../lib/git'; import {gitRepo, gitCommits, gitTagVersion} from './helpers/git-utils'; @@ -250,10 +249,10 @@ test.serial('Throw SemanticReleaseError if not running from a git repository', a // Verify error code and type t.is(error.code, 'ENOGITREPO'); - t.true(error instanceof SemanticReleaseError); + t.is(error.name, 'SemanticReleaseError'); }); -test.serial('Throw SemanticReleaseError if repositoryUrl is not set and canot be found', async t => { +test.serial('Throw SemanticReleaseError if repositoryUrl is not set and cannot be found', async t => { // Create a git repository, set the current working directory at the root of the repo await gitRepo(); @@ -261,7 +260,8 @@ test.serial('Throw SemanticReleaseError if repositoryUrl is not set and canot be // Verify error code and type t.is(error.code, 'ENOREPOURL'); - t.true(error instanceof SemanticReleaseError); + t.is(error.name, 'SemanticReleaseError'); +}); test.serial('Throw an Error if returns an unexpected value', async t => { // Create a git repository, set the current working directory at the root of the repo diff --git a/test/plugins/normalize.test.js b/test/plugins/normalize.test.js index d0957752..51711177 100644 --- a/test/plugins/normalize.test.js +++ b/test/plugins/normalize.test.js @@ -46,7 +46,7 @@ test('Wrap plugin in a function that validate the output of the plugin', async t await t.notThrows(plugin()); pluginFunction.resolves(2); - const error = await t.throws(plugin()); + const error = await t.throws(plugin(), Error); t.is(error.message, 'The output must be 1. Received: 2'); }); @@ -104,7 +104,7 @@ test('Always pass a defined "pluginConfig" for plugin defined with path', async }); test('Throws an error if the plugin return an object without the expected plugin function', t => { - const error = t.throws(() => normalize('inexistantPlugin', './test/fixtures/multi-plugin', t.context.logger)); + const error = t.throws(() => normalize('inexistantPlugin', './test/fixtures/multi-plugin', t.context.logger), Error); t.is( error.message, diff --git a/test/plugins/pipeline.test.js b/test/plugins/pipeline.test.js index ea26f2cf..3b35633c 100644 --- a/test/plugins/pipeline.test.js +++ b/test/plugins/pipeline.test.js @@ -32,7 +32,7 @@ test('Stop execution and throw error is a step rejects', async t => { const step2 = stub().throws(new Error('test error')); const step3 = stub().resolves(3); - const error = await t.throws(pipeline([step1, step2, step3])(0)); + const error = await t.throws(pipeline([step1, step2, step3])(0), 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 a4525cf0..edea9c9e 100644 --- a/test/plugins/plugins.test.js +++ b/test/plugins/plugins.test.js @@ -49,7 +49,7 @@ test('Use default when only options are passed for a single plugin', t => { }); test('Throw an error if plugin configuration is missing a path for plugin pipeline', t => { - const error = t.throws(() => getPlugins({verifyConditions: {}}, t.context.logger)); + const error = t.throws(() => getPlugins({verifyConditions: {}}, t.context.logger), Error); t.is( error.message, @@ -58,7 +58,10 @@ test('Throw an error if plugin configuration is missing a path for plugin pipeli }); test('Throw an error if an array of plugin configuration is missing a path for plugin pipeline', t => { - const error = t.throws(() => getPlugins({verifyConditions: [{path: '@semantic-release/npm'}, {}]}, t.context.logger)); + const error = t.throws( + () => getPlugins({verifyConditions: [{path: '@semantic-release/npm'}, {}]}, t.context.logger), + Error + ); t.is( error.message,