diff --git a/test/index.test.js b/test/index.test.js index 8e4c7fdc..67b69e4f 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -3,6 +3,7 @@ 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'; @@ -261,4 +262,30 @@ 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); + +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 + await gitRepo(); + // Add commits to the master branch + await gitCommits(['First']); + // Create the tag corresponding to version 1.0.0 + await gitTagVersion('v1.0.0'); + // Add new commits to the master branch + await gitCommits(['Second']); + + const verifyConditions = stub().resolves(); + const getLastRelease = stub().resolves('string'); + + const options = { + branch: 'master', + repositoryUrl: 'git@hostname.com:owner/module.git', + verifyConditions: [verifyConditions], + getLastRelease, + }; + + const error = await t.throws(t.context.semanticRelease(options), Error); + + // Verify error message + t.regex(error.message, new RegExp(DEFINITIONS.getLastRelease.output.message)); + t.regex(error.message, /Received: 'string'/); });