From 8b3e4b46b4153c6edec5d6846e9e7ad353964158 Mon Sep 17 00:00:00 2001 From: Karan Handa Date: Thu, 7 Mar 2024 22:59:40 +0530 Subject: [PATCH] chore: add errors --- package.json | 2 +- src/utils.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 0041551..b4b7dab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "million-lint-check", - "version": "1.0.10", + "version": "1.0.11", "description": "A command-line tool to verify if Million Lint is active in a project.", "main": "index.js", "files": [ diff --git a/src/utils.ts b/src/utils.ts index 83c0941..abd1ce8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -37,7 +37,7 @@ export async function checkWhetherMillionWorks( port: number, devServer: ChildPr const url = `http://localhost:${port}` const page = await tryConnect(url, browser, 100) if (!page) { - exit() + throw new Error("Could not connect to page!") } await page.goto(url, { waitUntil: ['networkidle0', 'load'] }); @@ -46,7 +46,7 @@ export async function checkWhetherMillionWorks( port: number, devServer: ChildPr await fuzzPage(page); // check whether the element that has class name 'million-embed' also has class name 'active' - console.log(`Finding element...`); + console.log(`Finding Million Element...`); const isActiveHandle = await page.evaluateHandle(() => { const element = document!.querySelector("body > div:nth-child(4)")!.shadowRoot!.querySelector("div > div") return element?.classList.contains('active') @@ -54,6 +54,8 @@ export async function checkWhetherMillionWorks( port: number, devServer: ChildPr const active = await isActiveHandle.jsonValue() if (active) { console.log('Million Lint is working as expected!'); + } else { + throw new Error('Million not working!') } await browser.close();