Skip to content

Commit

Permalink
default args and empty supergraph for e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed Aug 13, 2024
1 parent c737251 commit 3ab9e02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion e2e/top-level-await/top-level-await.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { createTenv } from '@e2e/tenv';
import { fetch } from '@whatwg-node/fetch';

const { serve, compose } = createTenv(__dirname);
const { serve, compose, fs } = createTenv(__dirname);

it('should serve', async () => {
const proc = await serve({
supergraph: await fs.tempfile('supergraph.graphql', 'type Query { hello: String }'),
args: ['--native-import'],
});
const res = await fetch(`http://0.0.0.0:${proc.port}/healthcheck`);
Expand Down
14 changes: 7 additions & 7 deletions e2e/utils/tenv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export function createTenv(cwd: string): Tenv {
return fs.writeFile(filePath, content, 'utf-8');
},
},
spawn(command, { args: extraArgs, ...opts }) {
spawn(command, { args: extraArgs = [], ...opts } = {}) {
const [cmd, ...args] = Array.isArray(command) ? command : command.split(' ');
return spawn({ ...opts, cwd }, String(cmd), ...args, ...extraArgs);
},
Expand All @@ -257,7 +257,7 @@ export function createTenv(cwd: string): Tenv {
pipeLogs = boolEnv('DEBUG'),
env,
runner,
args,
args = [],
} = opts || {};

let proc: Proc,
Expand Down Expand Up @@ -378,7 +378,7 @@ export function createTenv(cwd: string): Tenv {
maskServicePorts,
pipeLogs = boolEnv('DEBUG'),
env,
args,
args = [],
} = opts || {};
let output = '';
if (opts?.output) {
Expand Down Expand Up @@ -429,7 +429,7 @@ export function createTenv(cwd: string): Tenv {

return { ...proc, output, result };
},
async service(name, { port, servePort, pipeLogs = boolEnv('DEBUG'), args } = {}) {
async service(name, { port, servePort, pipeLogs = boolEnv('DEBUG'), args = [] } = {}) {
port ||= await getAvailablePort();
const [proc, waitForExit] = await spawn(
{ cwd, pipeLogs },
Expand Down Expand Up @@ -465,9 +465,9 @@ export function createTenv(cwd: string): Tenv {
additionalContainerPorts: containerAdditionalPorts,
healthcheck,
pipeLogs = boolEnv('DEBUG'),
cmd,
cmd = [],
volumes = [],
args,
args = [],
}) {
const containerName = `${name}_${Math.random().toString(32).slice(2)}`;

Expand Down Expand Up @@ -536,7 +536,7 @@ export function createTenv(cwd: string): Tenv {
{},
),
},
Cmd: [...(cmd || []), ...(args || [])].filter(Boolean).map(String),
Cmd: [...cmd, ...args].filter(Boolean).map(String),
HostConfig: {
AutoRemove: true,
PortBindings: {
Expand Down

0 comments on commit 3ab9e02

Please sign in to comment.