Skip to content

Commit

Permalink
Refactor clientside test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
thekevinscott committed Nov 21, 2023
1 parent d2e6fcd commit da1da43
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 7 additions & 2 deletions internals/common/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ export const getUMDNames = async (packageName: string): Promise<Record<string, s
}
}

const getAllAvailableModels = async (packageName: string): Promise<AvailableModel[]> => {
const getAllAvailableModels = async (packageName: string, includeIndex = false): Promise<AvailableModel[]> => {
const modelPackageDir = path.resolve(MODELS_DIR, packageName);
const umdNames = await getUMDNames(modelPackageDir);
const packageJSONExports = await getPackageJSONExports(modelPackageDir);
return packageJSONExports.filter(k => k[0] !== '.').map(([key, value]) => {
return packageJSONExports.filter(k => {
if (packageJSONExports.length > 1) {
return k[0] !== '.';
}
return true;
}).map(([key, value]) => {
const umdName = umdNames[key];
if (umdName === undefined) {
throw new Error(`No UMD name defined for ${packageName}/umd-names.json for ${key}`);
Expand Down
17 changes: 12 additions & 5 deletions internals/test-runner/src/ClientsideTestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ export class ClientsideTestRunner {
* Utility methods
*/

private _getLogMessage (msg: string) {
private _getLogMessage(msg: string) {
return [msg, this._name].filter(Boolean).join(' | ');
}

private _warn (msg: string) {
private _warn(msg: string) {
if (this.showWarnings) {
console.warn(this._getLogMessage(msg));// skipcq: JS-0002
}
Expand Down Expand Up @@ -219,9 +219,16 @@ export class ClientsideTestRunner {
}

public async startBrowser() {
// launch handles launching an instance and then connecting to it
this.browser = await launch({
headless: 'new',
protocolTimeout: 180_000 * 2,
});

// connect is for connecting to an already running instance
// this.browser = await connect({

// });
}

private _attachLogger() {
Expand All @@ -240,9 +247,9 @@ export class ClientsideTestRunner {
console.log(`[PAGE][response][${status}] ${response.url()}`);
}
})
.on('requestfailed', request => {
console.log(`[PAGE][requestfailed][${request.failure()?.errorText}] ${request.url()}`);
})
.on('requestfailed', request => {
console.log(`[PAGE][requestfailed][${request.failure()?.errorText}] ${request.url()}`);
})
}
}

Expand Down

0 comments on commit da1da43

Please sign in to comment.