@@ -7,6 +7,7 @@ import tempy from 'tempy';
77import clearModule from 'clear-module' ;
88import { WritableStreamBuffer } from 'stream-buffers' ;
99import npmRegistry from './helpers/npm-registry' ;
10+ import otpServer from './helpers/otp-server' ;
1011
1112/* eslint camelcase: ["error", {properties: "never"}] */
1213
@@ -23,6 +24,8 @@ const testEnv = {
2324test . before ( async ( ) => {
2425 // Start the local NPM registry
2526 await npmRegistry . start ( ) ;
27+ // Stop the test OTP server
28+ await otpServer . start ( ) ;
2629} ) ;
2730
2831test . beforeEach ( t => {
@@ -39,6 +42,8 @@ test.beforeEach(t => {
3942test . after . always ( async ( ) => {
4043 // Stop the local NPM registry
4144 await npmRegistry . stop ( ) ;
45+ // Stop the test OTP server
46+ await otpServer . start ( ) ;
4247} ) ;
4348
4449test ( 'Skip npm auth verification if "npmPublish" is false' , async t => {
@@ -285,6 +290,34 @@ test('Publish the package on a dist-tag', async t => {
285290 t . is ( ( await execa ( 'npm' , [ 'view' , pkg . name , 'version' ] , { cwd, env : testEnv } ) ) . stdout , '1.0.0' ) ;
286291} ) ;
287292
293+ test ( 'Publish the package with OTP' , async t => {
294+ const cwd = tempy . directory ( ) ;
295+ const env = npmRegistry . authEnv ;
296+ const pkg = { name : 'publish-otp' , version : '0.0.0' , publishConfig : { registry : npmRegistry . url } } ;
297+ await outputJson ( path . resolve ( cwd , 'package.json' ) , pkg ) ;
298+
299+ const { port, address} = otpServer . address ( ) ;
300+ const result = await t . context . m . publish (
301+ {
302+ otpUrl : `http://${ address } :${ port } /otp` ,
303+ } ,
304+ {
305+ cwd,
306+ env,
307+ options : { } ,
308+ stdout : t . context . stdout ,
309+ stderr : t . context . stderr ,
310+ logger : t . context . logger ,
311+ nextRelease : { version : '1.0.0' } ,
312+ }
313+ ) ;
314+
315+ t . deepEqual ( result , { name : 'npm package (@latest dist-tag)' , url : undefined } ) ;
316+ t . is ( ( await readJson ( path . resolve ( cwd , 'package.json' ) ) ) . version , '1.0.0' ) ;
317+ t . false ( await pathExists ( path . resolve ( cwd , `${ pkg . name } -1.0.0.tgz` ) ) ) ;
318+ t . is ( ( await execa ( 'npm' , [ 'view' , pkg . name , 'version' ] , { cwd, env : testEnv } ) ) . stdout , '1.0.0' ) ;
319+ } ) ;
320+
288321test ( 'Publish the package from a sub-directory' , async t => {
289322 const cwd = tempy . directory ( ) ;
290323 const env = npmRegistry . authEnv ;
0 commit comments