Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
6 changes: 3 additions & 3 deletions packages/instantsearch-cli/__tests__/global-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('global options', () => {
describe('--json implies --yes', () => {
it('sets yes=true when --json is passed', async () => {
const program = createProgram(silentIO);
await program.parseAsync(['init', '--json'], { from: 'user' });
await program.parseAsync(['add', '--json'], { from: 'user' });
Comment thread
sarahdayan marked this conversation as resolved.

expect(program.opts()).toMatchObject({ json: true, yes: true });
});
Expand All @@ -18,14 +18,14 @@ describe('global options', () => {
describe('--yes', () => {
it('is a standalone global flag (yes=true, json=false)', async () => {
const program = createProgram(silentIO);
await program.parseAsync(['init', '--yes'], { from: 'user' });
await program.parseAsync(['add', '--yes'], { from: 'user' });

expect(program.opts()).toMatchObject({ json: false, yes: true });
});

it('defaults to false when neither --yes nor --json is passed', async () => {
const program = createProgram(silentIO);
await program.parseAsync(['init'], { from: 'user' });
await program.parseAsync(['add'], { from: 'user' });

expect(program.opts()).toMatchObject({ json: false, yes: false });
});
Expand Down
2 changes: 1 addition & 1 deletion packages/instantsearch-cli/__tests__/human-output.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { runCapturing } from './__utils__/helpers';

describe.each(['init', 'add', 'introspect'])(
describe.each(['add', 'introspect'])(
'%s (no --json)',
(command) => {
it('emits human-readable output, not a JSON envelope', async () => {
Expand Down
47 changes: 47 additions & 0 deletions packages/instantsearch-cli/__tests__/init-exit-code.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import path from 'path';

import { runCapturing } from './__utils__/helpers';

const FIXTURES_ROOT = path.join(__dirname, 'fixtures', 'detector');

describe('init exit code', () => {
it('returns a non-zero process exit code when runInit fails', async () => {
const originalCwd = process.cwd();
process.chdir(path.join(FIXTURES_ROOT, 'vanilla'));
try {
const { exitCode } = await runCapturing([
'init',
'--json',
'--app-id',
'X',
'--search-api-key',
'Y',
]);

expect(exitCode).not.toBe(0);
} finally {
process.chdir(originalCwd);
}
});

it('surfaces the human-mode failure message on stderr', async () => {
const originalCwd = process.cwd();
process.chdir(path.join(FIXTURES_ROOT, 'vanilla'));
try {
const { exitCode, stdout, stderr } = await runCapturing([
'init',
'--yes',
'--app-id',
'X',
'--search-api-key',
'Y',
]);

expect(exitCode).not.toBe(0);
expect(stdout).toBe('');
expect(stderr).toMatch(/react/i);
} finally {
process.chdir(originalCwd);
}
});
});
Loading
Loading