Skip to content

Commit

Permalink
chore: Disable node warnings when spawning for tests
Browse files Browse the repository at this point in the history
Steven Bazyl committed Jan 9, 2025
1 parent ad6f871 commit a975d1d
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions test/commands/status.ts
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions test/functions.ts
Original file line number Diff line number Diff line change
@@ -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 */

0 comments on commit a975d1d

Please sign in to comment.