@@ -4,6 +4,7 @@ import * as fs from 'fs-extra'
44const path = require ( 'path' )
55const semver = require ( 'semver' )
66const os = require ( 'os' )
7+ const isCI = require ( 'is-ci' )
78
89const lastversioncheck = path . join ( __dirname , '../fixtures/lastversioncheck' )
910const upgradeavailable = path . join ( __dirname , '../fixtures/upgradeavailable' )
@@ -46,7 +47,11 @@ describe('Check if telemetry is set if config is null', () => {
4647 . stdout ( )
4748 . hook ( 'init' , { argv : [ 'arg' ] } , { root : rootTelemetryNull } )
4849 . do ( output => {
49- expect ( output . stdout ) . to . contain ( 'Telemetry will remain disabled' )
50+ if ( ! isCI ) {
51+ expect ( output . stdout ) . to . contain ( 'Telemetry will remain disabled' )
52+ } else {
53+ expect ( output . stdout ) . to . be . empty
54+ }
5055 } )
5156 . it ( 'it should disable telemetry when a user opts out' )
5257
@@ -56,7 +61,11 @@ describe('Check if telemetry is set if config is null', () => {
5661 . stdout ( )
5762 . hook ( 'init' , { argv : [ 'arg' ] } , { root : rootTelemetryNull } )
5863 . do ( output => {
59- expect ( output . stdout ) . to . contain ( 'Telemetry has been enabled' )
64+ if ( ! isCI ) {
65+ expect ( output . stdout ) . to . contain ( 'Telemetry has been enabled' )
66+ } else {
67+ expect ( output . stdout ) . to . be . empty
68+ }
6069 } )
6170 . it ( 'it should enable telemetry when a user opts in' )
6271} )
@@ -132,19 +141,24 @@ describe('Update available to stdout', () => {
132141} )
133142
134143describe ( 'bypass version update if it\'s already been checked today' , async ( ) => {
144+ let originalDate
135145 beforeEach ( async ( ) => {
136146 // runs before all tests in this block
137147 const today = new Date ( )
138148 let userConfig = await fs . readJSON ( path . join ( lastversioncheck , 'package.json' ) )
149+ originalDate = userConfig . lastversioncheck
139150 userConfig . lastversioncheck = today
140151 fs . writeFileSync ( path . join ( lastversioncheck , 'package.json' ) , JSON . stringify ( userConfig , null , 2 ) )
141152 fs . mkdirSync ( pathToConfigJsonUpdate )
142153 fs . writeFileSync ( path . join ( pathToConfigJsonUpdate , 'config.json' ) , JSON . stringify ( { telemetry : true } , null , 2 ) )
143154 } ) ;
144155
145- afterEach ( function ( ) {
156+ afterEach ( async function ( ) {
146157 // runs after all tests in this block
147158 fs . removeSync ( pathToConfigJsonUpdate )
159+ let userConfig = await fs . readJSON ( path . join ( lastversioncheck , 'package.json' ) )
160+ userConfig . lastversioncheck = originalDate
161+ fs . writeFileSync ( path . join ( lastversioncheck , 'package.json' ) , JSON . stringify ( userConfig , null , 2 ) )
148162 } ) ;
149163
150164 test
0 commit comments