Skip to content

Commit

Permalink
Merge b335be6 into 022a7f3
Browse files Browse the repository at this point in the history
  • Loading branch information
connectdotz committed Dec 4, 2021
2 parents 022a7f3 + b335be6 commit 38bda19
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/test-provider/test-provider-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,15 @@ export class JestTestProviderContext {
text = `${COLORS[color]}${text}${COLORS['end']}`;
}
run.appendOutput(`${text}${newLine ? '\r\n' : ''}`);
showTestExplorerTerminal();
};
}

/** show TestExplorer Terminal on first invocation only */
let showTerminal = true;
const showTestExplorerTerminal = () => {
if (showTerminal) {
showTerminal = false;
vscode.commands.executeCommand('testing.showMostRecentOutput');
}
};
14 changes: 7 additions & 7 deletions src/test-provider/test-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ export class JestTestProvider {
new vscode.TestRunRequest([theItem]),
`disoverTest: ${this.controller.id}`
);
const data = this.context.getData(theItem);
run.appendOutput(
`${
data ? `resolving children for ${theItem.id}\r\n` : `no data found for item ${theItem.id}`
}`
);
try {
data?.discoverTest?.(run);
const data = this.context.getData(theItem);
if (data) {
this.context.appendOutput(`resolving children for ${theItem.id}`, run, true);
data.discoverTest?.(run);
} else {
this.context.appendOutput(`no data found for item ${theItem.id}`, run, true, 'red');
}
} catch (e) {
this.log('error', `[JestTestProvider]: discoverTest error for "${theItem.id}" : `, e);
theItem.error = `discoverTest error: ${JSON.stringify(e)}`;
Expand Down
10 changes: 10 additions & 0 deletions tests/test-provider/test-item-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ describe('test-item-data', () => {
.mockImplementation((uri, p) => ({ fsPath: `${uri.fsPath}/${p}` }));
vscode.Uri.file = jest.fn().mockImplementation((f) => ({ fsPath: f }));
});
describe('show TestExplorer Terminal', () => {
it('show TestExplorer Terminal on first run output only', () => {
context.appendOutput('first time should open terminal', runMock);
expect(vscode.commands.executeCommand).toBeCalledTimes(1);
expect(vscode.commands.executeCommand).toBeCalledWith('testing.showMostRecentOutput');

context.appendOutput('subsequent calls will not open terminal again', runMock);
expect(vscode.commands.executeCommand).toBeCalledTimes(1);
});
});
describe('discover children', () => {
describe('WorkspaceRoot', () => {
it('create test document tree for testFiles list', () => {
Expand Down

0 comments on commit 38bda19

Please sign in to comment.