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

fix: session.project typing #370

Merged
merged 1 commit into from
Jan 4, 2023
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
12 changes: 6 additions & 6 deletions src/testSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ export interface TestSessionOptions {
* TESTKIT_HUB_INSTANCE = instance url for the hub. Defaults to https://login.salesforce.com
* TESTKIT_AUTH_URL = auth url to be used with auth:sfdxurl:store
*/
export class TestSession extends AsyncOptionalCreatable<TestSessionOptions> {
export class TestSession<T extends TestSessionOptions = TestSessionOptions> extends AsyncOptionalCreatable<T> {
public id: string;
public createdDate: Date;
public dir: string;
public homeDir: string;
public project?: TestProject;
public project!: T['project'] extends TestSessionOptions['project'] ? TestProject : TestProject | undefined;

// this is stored on the class so that tests can set it to something much lower than default
public rmRetryConfig: Partial<RetryConfig<void>> = { retries: 12, delay: 5000 };
Expand All @@ -115,15 +115,15 @@ export class TestSession extends AsyncOptionalCreatable<TestSessionOptions> {
private sandbox = createSandbox();
private retries: number;
private zipDir: typeof zipDir;
private options: TestSessionOptions;
private options: T;
private shelljsExecOptions: shell.ExecOptions = {
silent: true,
};
private orgsAliases: string[] = ['default'];

public constructor(options: TestSessionOptions = {}) {
super(options);
this.options = options;
public constructor(options: T = {} as T) {
super(options ?? ({} as T));
this.options = options ?? ({} as T);
this.debug = debug('testkit:session');
this.zipDir = zipDir;

Expand Down
1 change: 1 addition & 0 deletions test/unit/testSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ describe('TestSession', () => {
session = await TestSession.create();
stubMethod(sandbox, session, 'sleep').resolves();
// @ts-ignore session.sandbox is private
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
restoreSpy = spyMethod(sandbox, session.sandbox, 'restore');
});

Expand Down