@checksum-ai/runtime 2.0.10 → 2.0.12-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +1 -1
- package/cli.js +3 -1
- package/index.d.ts +2 -2
- package/index.js +133 -133
- package/package.json +1 -1
- package/pw-report-template.html +20 -20
- package/test-run-monitor.js +66 -66
- package/vtg-pw-bridge-runner.js +37 -37
package/.env
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
CHECKSUM_RUNTIME_BUILD_TIME=
|
|
1
|
+
CHECKSUM_RUNTIME_BUILD_TIME=2026-01-15T14:09:57.205Z
|
package/cli.js
CHANGED
|
@@ -1747,7 +1747,9 @@ Example:
|
|
|
1747
1747
|
`)}}};e(ewr,"CLIHelp");var vnt=ewr;var twr=class twr extends NP{constructor(r,a=!1){super(r,a,{skipChecksumDataLoad:!0})}async run(){let a=`npx playwright show-report ${this.getNonChecksumArgs().join(" ")}`;try{await this.execCmd(a)}catch(s){console.log("Error showing report",s.message)}}};e(twr,"CLIShowReport");var Jkt=twr;var NI=require("fs"),jK=require("path");AAe();Wme();var rwr=class rwr extends NP{constructor(r,a=!1){super(r,a,{skipChecksumDataLoad:!0})}init({requireChecksumFolder:r=!0}={}){try{this.findProjectRoot()}catch(a){console.log(a.message),process.exit(1)}if(this.checksumRoot=(0,jK.join)(process.cwd(),$Et),!(0,NI.existsSync)(this.checksumRoot)){if(r)throw new Error("Could not find checksum folder in your project, you should run the init command first to setup your Checksum.ai project.");(0,NI.mkdirSync)(this.checksumRoot)}if(!(0,NI.existsSync)(this.getChecksumRootOrigin()))throw new Error("Could not find checksum node module, please install @checksum-ai/runtime package and try again.")}install(){console.log("Creating checksum directory and necessary files to run your tests..."),this.init({requireChecksumFolder:!1});let r=(0,NI.existsSync)((0,jK.join)(this.checksumRoot,"checksum.config.ts"));hOr({isInit:!r}).forEach(l=>{let d=(0,jK.join)(this.checksumRoot,l);(0,NI.existsSync)(d)||(0,NI.copyFileSync)((0,jK.join)(this.getChecksumRootOrigin(),l),d)});let a=(0,jK.join)(this.checksumRoot,".gitignore.example"),s=(0,jK.join)(this.checksumRoot,".gitignore");(0,NI.existsSync)(a)&&!(0,NI.existsSync)(s)&&((0,NI.copyFileSync)(a,s),(0,NI.unlinkSync)(a)),this.validateAuthExists(),(0,NI.mkdirSync)((0,jK.join)(this.checksumRoot,"tests"),{recursive:!0})}addTsConfig(){console.log("Adding tsconfig.json to your checksum directory..."),this.init();let r=(0,jK.join)(this.checksumRoot,"tsconfig.json");(0,NI.existsSync)(r)||(0,NI.copyFileSync)((0,jK.join)(this.getChecksumRootOrigin(),"tsconfig.json"),r)}async addEslintConfig(){console.log("Adding ESLint config to your checksum directory..."),this.init();let r=(0,jK.join)(this.checksumRoot,"eslint.config.js");(0,NI.existsSync)(r)?console.log("eslint.config.js already exists."):((0,NI.copyFileSync)((0,jK.join)(this.getChecksumRootOrigin(),"eslint.config.js"),r),console.log("Added eslint.config.js."));let a=["eslint","@eslint/js","typescript","typescript-eslint"],s=this.getChecksumArg("yes"),l=!!s;if(!s)try{l=await Ctt({message:`Install required devDependencies now? (${a.join(", ")})`,choices:[{name:"Yes",value:"yes"},{name:"No",value:"no"}],default:"yes"})==="yes"}catch{l=!1}if(l){let g=(0,NI.existsSync)((0,jK.join)(this.projectRootDirectory,"yarn.lock"))?`yarn add -D ${a.join(" ")}`:`npm i -D ${a.join(" ")}`;try{console.log("Installing devDependencies...",g),await this.execCmd(`cd "${this.projectRootDirectory}" && ${g}`),console.log("DevDependencies installed successfully.")}catch(b){console.log("Failed installing devDependencies:",b.message)}}else console.log(`Skipped installing devDependencies. You can install them manually with:
|
|
1748
1748
|
npm i -D `+a.join(" ")+`
|
|
1749
1749
|
or
|
|
1750
|
-
yarn add -D `+a.join(" "))}};e(rwr,"CLIInstall");var MLe=rwr;e7();var nwr=class nwr extends NP{constructor(r,a=!1){super(r,a);let s=r[0];this.vtgTestFileParser=new xwe(s)}async run(){this.vtgTestFileParser.loadTestsFromFile();let r=this.vtgTestFileParser.testMirrors[0].translateStatementsToSteps();VA.info("Test steps:",JSON.stringify(r,null,2))}};e(nwr,"VtgTestFileParser");var zkt=nwr;var HAn=require("fs"),GAn=qd(require("path"));xz();xCr();var iwr=class iwr extends WRe{constructor(a){super(a,"/client-api/runtime");this.config=a}};e(iwr,"CliAPIService");var Wkt=iwr;var awr=class awr extends NP{constructor(r,a=!1){super(r,a,{muteChecksumConfigMissingError:!0}),this.config.apiURL||(this.config.apiURL=Hcn({}).apiURL)}async initApiService(){let r=this.config.apiKey,a=this.getArg("--api-key");a&&a!==""?this.config.apiKey=a:!!r?this.config.apiKey=r:this.handleError("No API key provided. Please provide an API key using --api-key=<apiKey>"),this.apiService=new Wkt(this.config)}async downloadDotenv(){try{let r=await this.apiService.get("dotenv");if(!r.ok){let{status:l,statusText:d}=r;l===403&&this.handleError('The API key you provided is not valid. Please check your API key and try again, running: "npx checksumai dotenv --download --api-key=<apiKey>"'),this.handleError(`Error occured when trying to download the .env file. ${l} ${d}`)}let a=await r.text()
|
|
1750
|
+
yarn add -D `+a.join(" "))}};e(rwr,"CLIInstall");var MLe=rwr;e7();var nwr=class nwr extends NP{constructor(r,a=!1){super(r,a);let s=r[0];this.vtgTestFileParser=new xwe(s)}async run(){this.vtgTestFileParser.loadTestsFromFile();let r=this.vtgTestFileParser.testMirrors[0].translateStatementsToSteps();VA.info("Test steps:",JSON.stringify(r,null,2))}};e(nwr,"VtgTestFileParser");var zkt=nwr;var HAn=require("fs"),GAn=qd(require("path"));xz();xCr();var iwr=class iwr extends WRe{constructor(a){super(a,"/client-api/runtime");this.config=a}};e(iwr,"CliAPIService");var Wkt=iwr;var awr=class awr extends NP{constructor(r,a=!1){super(r,a,{muteChecksumConfigMissingError:!0}),this.config.apiURL||(this.config.apiURL=Hcn({}).apiURL)}async initApiService(){let r=this.config.apiKey,a=this.getArg("--api-key");a&&a!==""?this.config.apiKey=a:!!r?this.config.apiKey=r:this.handleError("No API key provided. Please provide an API key using --api-key=<apiKey>"),this.apiService=new Wkt(this.config)}async downloadDotenv(){try{let r=await this.apiService.get("dotenv");if(!r.ok){let{status:l,statusText:d}=r;l===403&&this.handleError('The API key you provided is not valid. Please check your API key and try again, running: "npx checksumai dotenv --download --api-key=<apiKey>"'),this.handleError(`Error occured when trying to download the .env file. ${l} ${d}`)}let a=await r.text();a=this.removeAuthorizeReports(a);let s=GAn.default.join(this.checksumRoot,".env");(0,HAn.writeFileSync)(s,a),console.log(`The .env file has been downloaded to ${s}`)}catch{this.handleError("Error occured when trying to download the .env file.")}}async run(){await this.initApiService(),this.getArg("--download")?await this.downloadDotenv():this.handleError("Invalid command. Use --download to download the .env file and run the command again.")}handleError(r){console.error(r),process.exit(1)}removeAuthorizeReports(r){return r.split(`
|
|
1751
|
+
`).filter(l=>!l.trim().toUpperCase().startsWith("AUTHORIZE_REPORTS=")).join(`
|
|
1752
|
+
`)}};e(awr,"CLIDotEnvManager");var Hkt=awr;var Hwe=require("fs"),swr=require("path");var owr=class owr extends NP{constructor(a,s=!1){super(a,s,{skipChecksumDataLoad:!0});this.packagesToOverride=["playwright-core","playwright"]}async run(){var a,s;try{console.log("Validating Playwright version..."),this.findProjectRoot();let l=(0,swr.join)(this.projectRootDirectory,"node_modules","@checksum-ai","runtime","package.json");if(!(0,Hwe.existsSync)(l))throw new Error(`package.json not found in: ${l}`);let d=JSON.parse((0,Hwe.readFileSync)(l,"utf8")),g=((a=d.dependencies)==null?void 0:a["@playwright/test"])||((s=d.devDependencies)==null?void 0:s["@playwright/test"]);if(!g)throw new Error(`No @playwright/test dependency found in ${l}`);let b=await this.getCurrentPlaywrightVersions();console.log(`Expected Playwright version: ${g}`);let E=b.filter(S=>!this.versionsMatch(g,S.version));if(E.length>0){console.log("\u274C Playwright version conflicts detected:"),E.forEach(({packageName:S,version:F})=>{console.log(` - Found version: ${S}@${F} (expected: ${g})`)}),console.log("\u{1F527} Attempting to fix Playwright version conflicts...");try{let S=[];for(let{packageName:F}of E){if(S.includes(F))continue;await this.fixPlaywrightConflicts(F,g)&&S.push(F)}S.length>0&&(console.log("Running npm install to apply the override..."),await this.execCmd("npm install"),console.log("\u2705 Playwright version conflicts have been resolved"))}catch(S){console.log(String(S)),console.log("\u274C Failed to fix Playwright version conflicts automatically"),console.log("Please manually add the following to your package.json:"),console.log('"overrides": {');for(let{packageName:F}of E)console.log(` "${F}": "${g}"`);return console.log("}"),console.log("Then run 'npm install'"),!1}}else console.log("\u2705 Playwright version validation passed");return!0}catch(l){return console.error("Error validating Playwright version:",l.message),!1}}async getCurrentPlaywrightVersions(){try{let a=[];for(let s of this.packagesToOverride){let l=await this.getCmdOutput(`npm list ${s}`),d=new RegExp(`${s.replace("@","")}@([^@\\s]+)`,"g"),g;for(;(g=d.exec(l))!==null;)a.push({packageName:s,version:g[1]})}return a}catch{throw new Error("Could not determine current Playwright versions")}}versionsMatch(a,s){let l=a.replace(/^[\^~]/,""),d=s.replace(/^[\^~]/,"");return l===d}async fixPlaywrightConflicts(a,s){let l=(0,swr.join)(this.projectRootDirectory,"package.json"),d;try{d=JSON.parse((0,Hwe.readFileSync)(l,"utf8"))}catch{throw new Error("No package.json found in project root")}return d.overrides||(d.overrides={}),d.overrides[a]&&this.versionsMatch(d.overrides[a],s)?(console.log(`\u2705 Playwright version ${s} is already set as override in package.json`),!1):(d.overrides[a]=s,(0,Hwe.writeFileSync)(l,JSON.stringify(d,null,2)),console.log(`\u2705 Added ${a} override to package.json: ${s}`),!0)}};e(owr,"CLIValidatePlaywrightVersion");var jLe=owr;var cwr=class cwr extends NP{constructor(r,a=!1){super(r,a,{skipChecksumDataLoad:!0})}async run(){console.log("Running postinstall processes...");try{return console.log("Running Playwright version validation..."),await new jLe(this.args,this.debugMode).run()||console.log("\u26A0\uFE0F Playwright version validation failed, but continuing with postinstall..."),console.log("\u2705 Postinstall processes completed"),!0}catch(r){return console.error("Error during postinstall:",r.message),!1}}};e(cwr,"CLIPostinstall");var Gkt=cwr;pS();var uwr=class uwr{constructor(){}async execute(){let r=eg.useCLIDebug||!!process.argv.find(s=>s==="--cksm-clidebug"||s==="--cksm-repl"||s==="--cksm-debug");r&&wEr(!0);let a=process.argv.slice(3);switch(process.argv.find(s=>s==="--help"||s==="-h")&&(await new vnt(a,r).run(process.argv[2]),process.exit(0)),process.argv[2]){case"init":new MLe(a,r).install();break;case"tsconfig":new MLe(a,r).addTsConfig();break;case"eslint":await new MLe(a,r).addEslintConfig();break;case"test":await new ynt(a,r).run();return;case"show-report":await new Jkt(a,r).run();break;case"dotenv":await new Hkt(a,r).run();break;case"vtg":let s=e(l=>a.find(d=>d===l),"hasArg");if(s("--cksm-new-file"))throw Error("VTG new file mode is now the default. Remove the --cksm-new-file flag and run again with `vtg [story-id]`");if(s("--cksm-file"))throw Error("VTG edit file mode is now run using the --cksm-edit instead of --cksm-file flag, Run again with `vtg --cksm-edit [absolute-path-to-file]`");if(s("--cloud")&&!s("--cksm-legacy"))throw Error("VTG cloud mode can only be run in legacy mode. Use the --cksm-legacy flag to run in legacy mode with `vtg [story-id] --cksm-legacy --cloud`");try{if(s("--cksm-legacy"))throw Error("VTG in legacy mode is not supported anymore. To support we need to pass checksum config to it for it to work again.");let l=s("--headed")?a:["--headed",...a];eg.CI&&(l=l.filter(d=>d!=="--headed")),await new ynt(l,r,!0).run()}catch(l){console.log("Error",l.message)}break;case"vtg-test-parser":await new zkt(a,r).run();break;case"validate-playwright-version":await new jLe(a,r).run();break;case"postinstall":await new Gkt(a,r).run();break;default:await new vnt(a,r).run()}process.exit(0)}};e(uwr,"CLIDispatcher");var Kkt=uwr;(async()=>await new Kkt().execute())();
|
|
1751
1753
|
/*! Bundled license information:
|
|
1752
1754
|
|
|
1753
1755
|
lodash/lodash.js:
|
package/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
// import { ExpectWrapper } from "./index.helpers";
|
|
15
15
|
interface ChecksumAIMethod {
|
|
16
16
|
(title: string): IChecksumPage;
|
|
17
|
-
<T>(title: string, body: () => T | Promise<T
|
|
17
|
+
<T>(title: string, body: () => T | Promise<T>, options?: ChecksumAIOptions): Promise<T>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
type EnumValues<T> = T[keyof T];
|
|
@@ -335,7 +335,7 @@ export type ChecksumAIOptions = {
|
|
|
335
335
|
skipAutoRecovery?: boolean;
|
|
336
336
|
};
|
|
337
337
|
export type ChecksumAI = {
|
|
338
|
-
(description: string, testFunction: Function): Promise<any>;
|
|
338
|
+
(description: string, testFunction: Function, options?: ChecksumAIOptions): Promise<any>;
|
|
339
339
|
} & {
|
|
340
340
|
[K in keyof ChecksumAIOptions]: ChecksumAI;
|
|
341
341
|
};
|