11import test from 'ava' ;
22import nock from 'nock' ;
33import { stub } from 'sinon' ;
4- import SemanticReleaseError from '@semantic-release/error' ;
54import verify from '../lib/verify' ;
65import { authenticate } from './helpers/mock-github' ;
76
@@ -147,29 +146,29 @@ test.serial('Throw SemanticReleaseError if "assets" option is not a String or an
147146 process . env . GITHUB_TOKEN = 'github_token' ;
148147 const assets = 42 ;
149148
150- const error = await t . throws (
149+ const [ error ] = await t . throws (
151150 verify (
152151 { assets} ,
153152 { options : { repositoryUrl : 'https://github.com/semantic-release/github.git' } , logger : t . context . logger }
154153 )
155154 ) ;
156155
157- t . true ( error instanceof SemanticReleaseError ) ;
156+ t . is ( error . name , ' SemanticReleaseError' ) ;
158157 t . is ( error . code , 'EINVALIDASSETS' ) ;
159158} ) ;
160159
161160test . serial ( 'Throw SemanticReleaseError if "assets" option is an Array with invalid elements' , async t => {
162161 process . env . GITHUB_TOKEN = 'github_token' ;
163162 const assets = [ 'file.js' , 42 ] ;
164163
165- const error = await t . throws (
164+ const [ error ] = await t . throws (
166165 verify (
167166 { assets} ,
168167 { options : { repositoryUrl : 'https://github.com/semantic-release/github.git' } , logger : t . context . logger }
169168 )
170169 ) ;
171170
172- t . true ( error instanceof SemanticReleaseError ) ;
171+ t . is ( error . name , ' SemanticReleaseError' ) ;
173172 t . is ( error . code , 'EINVALIDASSETS' ) ;
174173} ) ;
175174
@@ -257,14 +256,14 @@ test.serial('Throw SemanticReleaseError if "assets" option is an Object missing
257256 process . env . GITHUB_TOKEN = 'github_token' ;
258257 const assets = { name : 'file.js' } ;
259258
260- const error = await t . throws (
259+ const [ error ] = await t . throws (
261260 verify (
262261 { assets} ,
263262 { options : { repositoryUrl : 'https://github.com/semantic-release/github.git' } , logger : t . context . logger }
264263 )
265264 ) ;
266265
267- t . true ( error instanceof SemanticReleaseError ) ;
266+ t . is ( error . name , ' SemanticReleaseError' ) ;
268267 t . is ( error . code , 'EINVALIDASSETS' ) ;
269268} ) ;
270269
@@ -274,24 +273,24 @@ test.serial(
274273 process . env . GITHUB_TOKEN = 'github_token' ;
275274 const assets = [ { path : 'lib/file.js' } , { name : 'file.js' } ] ;
276275
277- const error = await t . throws (
276+ const [ error ] = await t . throws (
278277 verify (
279278 { assets} ,
280279 { options : { repositoryUrl : 'https://github.com/semantic-release/github.git' } , logger : t . context . logger }
281280 )
282281 ) ;
283282
284- t . true ( error instanceof SemanticReleaseError ) ;
283+ t . is ( error . name , ' SemanticReleaseError' ) ;
285284 t . is ( error . code , 'EINVALIDASSETS' ) ;
286285 }
287286) ;
288287
289288test . serial ( 'Throw SemanticReleaseError for missing github token' , async t => {
290- const error = await t . throws (
289+ const [ error ] = await t . throws (
291290 verify ( { } , { options : { repositoryUrl : 'https://github.com/semantic-release/github.git' } , logger : t . context . logger } )
292291 ) ;
293292
294- t . true ( error instanceof SemanticReleaseError ) ;
293+ t . is ( error . name , ' SemanticReleaseError' ) ;
295294 t . is ( error . code , 'ENOGHTOKEN' ) ;
296295} ) ;
297296
@@ -303,21 +302,21 @@ test.serial('Throw SemanticReleaseError for invalid token', async t => {
303302 . get ( `/repos/${ owner } /${ repo } ` )
304303 . reply ( 401 ) ;
305304
306- const error = await t . throws (
305+ const [ error ] = await t . throws (
307306 verify ( { } , { options : { repositoryUrl : `https://github.com:${ owner } /${ repo } .git` } , logger : t . context . logger } )
308307 ) ;
309308
310- t . true ( error instanceof SemanticReleaseError ) ;
309+ t . is ( error . name , ' SemanticReleaseError' ) ;
311310 t . is ( error . code , 'EINVALIDGHTOKEN' ) ;
312311 t . true ( github . isDone ( ) ) ;
313312} ) ;
314313
315314test . serial ( 'Throw SemanticReleaseError for invalid repositoryUrl' , async t => {
316315 process . env . GITHUB_TOKEN = 'github_token' ;
317316
318- const error = await t . throws ( verify ( { } , { options : { repositoryUrl : 'invalid_url' } , logger : t . context . logger } ) ) ;
317+ const [ error ] = await t . throws ( verify ( { } , { options : { repositoryUrl : 'invalid_url' } , logger : t . context . logger } ) ) ;
319318
320- t . true ( error instanceof SemanticReleaseError ) ;
319+ t . is ( error . name , ' SemanticReleaseError' ) ;
321320 t . is ( error . code , 'EINVALIDGITURL' ) ;
322321} ) ;
323322
@@ -329,11 +328,11 @@ test.serial("Throw SemanticReleaseError if token doesn't have the push permissio
329328 . get ( `/repos/${ owner } /${ repo } ` )
330329 . reply ( 200 , { permissions : { push : false } } ) ;
331330
332- const error = await t . throws (
331+ const [ error ] = await t . throws (
333332 verify ( { } , { options : { repositoryUrl : `https://github.com:${ owner } /${ repo } .git` } , logger : t . context . logger } )
334333 ) ;
335334
336- t . true ( error instanceof SemanticReleaseError ) ;
335+ t . is ( error . name , ' SemanticReleaseError' ) ;
337336 t . is ( error . code , 'EGHNOPERMISSION' ) ;
338337 t . true ( github . isDone ( ) ) ;
339338} ) ;
@@ -346,11 +345,11 @@ test.serial("Throw SemanticReleaseError if the repository doesn't exist", async
346345 . get ( `/repos/${ owner } /${ repo } ` )
347346 . reply ( 404 ) ;
348347
349- const error = await t . throws (
348+ const [ error ] = await t . throws (
350349 verify ( { } , { options : { repositoryUrl : `https://github.com:${ owner } /${ repo } .git` } , logger : t . context . logger } )
351350 ) ;
352351
353- t . true ( error instanceof SemanticReleaseError ) ;
352+ t . is ( error . name , ' SemanticReleaseError' ) ;
354353 t . is ( error . code , 'EMISSINGREPO' ) ;
355354 t . true ( github . isDone ( ) ) ;
356355} ) ;
@@ -372,9 +371,8 @@ test.serial('Throw error if github return any other errors', async t => {
372371} ) ;
373372
374373test ( 'Throw SemanticReleaseError if "successComment" option is not a String' , async t => {
375- process . env . GITHUB_TOKEN = 'github_token' ;
376374 const successComment = 42 ;
377- const error = await t . throws (
375+ const [ error ] = await t . throws (
378376 verify (
379377 { successComment} ,
380378 { options : { repositoryUrl : 'https://github.com/semantic-release/github.git' } , logger : t . context . logger }
@@ -386,9 +384,8 @@ test('Throw SemanticReleaseError if "successComment" option is not a String', as
386384} ) ;
387385
388386test ( 'Throw SemanticReleaseError if "successComment" option is an empty String' , async t => {
389- process . env . GITHUB_TOKEN = 'github_token' ;
390387 const successComment = '' ;
391- const error = await t . throws (
388+ const [ error ] = await t . throws (
392389 verify (
393390 { successComment} ,
394391 { options : { repositoryUrl : 'https://github.com/semantic-release/github.git' } , logger : t . context . logger }
@@ -400,9 +397,8 @@ test('Throw SemanticReleaseError if "successComment" option is an empty String',
400397} ) ;
401398
402399test ( 'Throw SemanticReleaseError if "successComment" option is a whitespace String' , async t => {
403- process . env . GITHUB_TOKEN = 'github_token' ;
404400 const successComment = ' \n \r ' ;
405- const error = await t . throws (
401+ const [ error ] = await t . throws (
406402 verify (
407403 { successComment} ,
408404 { options : { repositoryUrl : 'https://github.com/semantic-release/github.git' } , logger : t . context . logger }
0 commit comments