diff --git a/test/commands/status.ts b/test/commands/status.ts index 31defdae..dbd76fc1 100644 --- a/test/commands/status.ts +++ b/test/commands/status.ts @@ -16,7 +16,7 @@ describe('Test clasp status function', () => { {file: 'should/alsoBeIgnored', data: TEST_CODE_JS}, ]); const result = runClasp(['status', '--json'], {cwd: tmpdir}); - const resultJson = JSON.parse(result.stdout.toString('utf-8')); + const resultJson = JSON.parse(result.stdout); expect(resultJson.untrackedFiles).to.have.members([ '.clasp.json', '.claspignore', // TODO Should these be untracked? @@ -36,7 +36,7 @@ describe('Test clasp status function', () => { {file: 'node_modules/fsevents/build/Release/.deps/Release/.node.d', data: TEST_CODE_JS}, ]); const result = runClasp(['status', '--json'], {cwd: tmpdir}); - const resultJson = JSON.parse(result.stdout.toString('utf-8')); + const resultJson = JSON.parse(result.stdout); expect(resultJson.untrackedFiles).to.have.members([ '.clasp.json', '.claspignore', // TODO Should these be untracked? @@ -57,7 +57,7 @@ describe('Test clasp status function', () => { {file: 'dist/should/alsoBeIgnored', data: TEST_CODE_JS}, ]); const result = runClasp(['status', '--json'], {cwd: tmpdir}); - const resultJson = JSON.parse(result.stdout.toString('utf-8')); + const resultJson = JSON.parse(result.stdout); expect(result.stderr).to.equal(''); expect(result.status).to.equal(0); expect(resultJson.untrackedFiles).to.have.members(['dist/should/alsoBeIgnored', 'dist/shouldBeIgnored']); @@ -76,7 +76,7 @@ describe('Test clasp status function', () => { const result = runClasp(['status', '--json'], {cwd: tmpdir + '/src'}); expect(result.stderr).to.equal(''); expect(result.status).to.equal(0); - const resultJson = JSON.parse(result.stdout.toString('utf-8')); + const resultJson = JSON.parse(result.stdout); expect(resultJson.untrackedFiles).to.have.members(['../build/should/alsoBeIgnored', '../build/shouldBeIgnored']); expect(resultJson.filesToPush).to.have.members(['../build/main.js', '../build/appsscript.json']); // TODO: cleanup by del/rimraf tmpdir diff --git a/test/functions.ts b/test/functions.ts index bd6fc895..2da596d1 100644 --- a/test/functions.ts +++ b/test/functions.ts @@ -11,14 +11,14 @@ import { import {spawnSync} from 'child_process'; export function runClasp(args: string[], opts = {}) { - const options = Object.assign( - {}, - { - encoding: 'utf8', + return spawnSync('node', [`${process.cwd()}/build/src/index.js`, ...args], { + encoding: 'utf8', + env: { + ...process.env, + NODE_NO_WARNINGS: '1', }, - opts ?? {} - ); - return spawnSync('node', [`${process.cwd()}/build/src/index.js`, ...args], options); + ...opts, + }); } /** basic cleanup after tests */