Skip to content

Commit

Permalink
Refactor clientside test setup (#1269)
Browse files Browse the repository at this point in the history
* Refactor clientside test setup
  • Loading branch information
thekevinscott authored Nov 21, 2023
1 parent 516a2c7 commit b26d05f
Show file tree
Hide file tree
Showing 5 changed files with 338 additions and 89 deletions.
7 changes: 6 additions & 1 deletion internals/common/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ const getAllAvailableModels = async (packageName: string): Promise<AvailableMode
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@
"./packages/upscalerjs:build:browser",
"build:models:esm",
"build:models:umd",
"bundle:esbuild",
"bundle:webpack",
"bundle:esbuild",
"bundle:umd"
]
},
Expand Down
Loading

0 comments on commit b26d05f

Please sign in to comment.