@@ -2,32 +2,33 @@ import {stat} from 'node:fs/promises';
22import { resolve } from 'node:path' ;
33import { escape } from 'node:querystring' ;
44
5+ import nock from 'nock' ;
6+ import quibble from "quibble"
7+ import sinon from 'sinon' ;
8+ import tempy from 'tempy' ;
59import test from 'ava' ;
6- import { cleanAll } from 'nock' ;
7- import { stub } from 'sinon' ;
8- import proxyquire from 'proxyquire' ;
9- import { directory } from 'tempy' ;
1010
1111import { authenticate , upload } from './helpers/mock-github.js' ;
12- import rateLimit from './helpers/rate-limit.js' ;
12+ import * as RATE_LIMIT_MOCK from './helpers/rate-limit.js' ;
1313
1414/* eslint camelcase: ["error", {properties: "never"}] */
1515
16+ // mock rate limit imported via lib/get-client.js
17+ await quibble . esm ( '../lib/definitions/rate-limit.js' , RATE_LIMIT_MOCK ) // eslint-disable-line
18+ const publish = ( await import ( '../lib/publish.js' ) ) . default
19+
1620const cwd = 'test/fixtures/files' ;
17- const publish = proxyquire ( '../lib/publish' , {
18- './get-client' : proxyquire ( '../lib/get-client' , { './definitions/rate-limit' : rateLimit } ) ,
19- } ) ;
2021
2122test . beforeEach ( ( t ) => {
2223 // Mock logger
23- t . context . log = stub ( ) ;
24- t . context . error = stub ( ) ;
24+ t . context . log = sinon . stub ( ) ;
25+ t . context . error = sinon . stub ( ) ;
2526 t . context . logger = { log : t . context . log , error : t . context . error } ;
2627} ) ;
2728
2829test . afterEach . always ( ( ) => {
2930 // Clear nock
30- cleanAll ( ) ;
31+ nock . cleanAll ( ) ;
3132} ) ;
3233
3334test . serial ( 'Publish a release' , async ( t ) => {
@@ -334,7 +335,7 @@ test.serial('Publish a release with an array of missing assets', async (t) => {
334335 const owner = 'test_user' ;
335336 const repo = 'test_repo' ;
336337 const env = { GITHUB_TOKEN : 'github_token' } ;
337- const emptyDirectory = directory ( ) ;
338+ const emptyDirectory = tempy . directory ( ) ;
338339 const pluginConfig = { assets : [ emptyDirectory , { path : 'missing.txt' , name : 'missing.txt' } ] } ;
339340 const nextRelease = { gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
340341 const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
0 commit comments