Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: remove -e in favor of NODE_ENV #318

Merged
merged 1 commit into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions __tests__/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,29 @@ describe('CLI', () => {
expect(await cli.exitCode).toBe(0);
});

it('pass config to journey params', async () => {
const cli = new CLIMock([
join(FIXTURES_DIR, 'fake.journey.ts'),
'--json',
'--config',
join(FIXTURES_DIR, 'synthetics.config.ts'),
'-e',
'testing',
]);
await cli.waitFor('journey/start');
expect(await cli.exitCode).toBe(0);
const output = cli.output();
expect(JSON.parse(output).payload).toMatchObject({
it('pass dynamic config to journey params', async () => {
// jest by default sets NODE_ENV to `test`
const original = process.env['NODE_ENV'];
const output = async () => {
const cli = new CLIMock([
join(FIXTURES_DIR, 'fake.journey.ts'),
'--json',
'--config',
join(FIXTURES_DIR, 'synthetics.config.ts'),
]);
await cli.waitFor('journey/start');
expect(await cli.exitCode).toBe(0);
return cli.output();
};

expect(JSON.parse(await output()).payload).toMatchObject({
params: { url: 'non-dev' },
});
process.env['NODE_ENV'] = 'development';
expect(JSON.parse(await output()).payload).toMatchObject({
params: { url: 'dev' },
});
process.env['NODE_ENV'] = original;
});

it('suite params wins over config params', async () => {
Expand Down
5 changes: 2 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,9 @@ async function prepareSuites(inputs: string[]) {
}

/**
* Use the NODE_ENV variable to control the environment if its not explicity
* passed from either CLI or through the API
* Use the NODE_ENV variable to control the environment
*/
const environment = options.environment || process.env['NODE_ENV'];
const environment = process.env['NODE_ENV'] || 'development';
/**
* Validate and handle configs
*/
Expand Down
1 change: 0 additions & 1 deletion src/common_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export type ScreenshotOptions = 'on' | 'off' | 'only-on-failure';
export type CliArgs = {
capability?: Array<string>;
config?: string;
environment?: string;
outfd?: number;
headless?: boolean;
screenshots?: ScreenshotOptions;
Expand Down
1 change: 1 addition & 0 deletions src/core/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type RunOptions = Omit<
| 'richEvents'
| 'capability'
> & {
environment?: string;
params?: Params;
reporter?: CliArgs['reporter'] | Reporter;
};
Expand Down
1 change: 0 additions & 1 deletion src/parse_args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ program
'configuration path (default: synthetics.config.js)'
)
.option('-s, --suite-params <jsonstring>', 'suite variables', '{}')
.option('-e, --environment <envname>', 'e.g. production', 'development')
.option('-j, --json', 'output newline delimited JSON')
.addOption(
new Option('--reporter <value>', `output repoter format`).choices(
Expand Down