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 import puppeteer #23

Merged
merged 5 commits into from
Oct 18, 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
4 changes: 4 additions & 0 deletions dist/hstest/environment/page.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/hstest/environment/page.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/hstest/stage/stageTest.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 21 additions & 22 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hs-test-web-ts",
"version": "4.0.1",
"version": "4.1.1",
"description": "Hyperskill Testing Library on TypeScript",
"main": "dist/hstest/index.js",
"scripts": {
Expand All @@ -11,33 +11,32 @@
"keywords": [],
"author": "Vladimir Turov & Ainur Gimadeev",
"dependencies": {
"@types/callsite": "^1.0.31",
"@types/callsite": "^1.0.32",
"callsite": "^1.0.0",
"puppeteer": "^13.0.0",
"puppeteer-element2selector": "^0.0.3"
"puppeteer": "21.0.0",
"puppeteer-element2selector": "0.0.3"
},
"devDependencies": {
"@babel/core": ">=7.9.6",
"@babel/preset-env": ">=7.9.6",
"@babel/preset-react": ">=7.9.4",
"@types/puppeteer": "^5.4.4",
"@types/webpack": "4.4.17",
"@types/webpack-dev-server": "3.1.1",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"babel-loader": "^8.2.3",
"chai": "^4.3.4",
"css-loader": "^5.2.1",
"eslint": "^8.7.0",
"@types/webpack": "5.28.2",
"@types/webpack-dev-server": "4.7.2",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"babel-loader": "^9.1.3",
"chai": "^4.3.8",
"css-loader": "^6.8.1",
"eslint": "^8.48.0",
"file-loader": ">=6.0.0",
"mocha": "^9.1.3",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"style-loader": "^1.2.1",
"mocha": "10.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"style-loader": "^3.3.3",
"ts-node": "^10.4.0",
"typescript": "^4.5.4",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^4.11.1"
"typescript": "^5.2.2",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
}
}
}
14 changes: 10 additions & 4 deletions hstest/environment/page.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import puppeteer, {ElementHandle, EvaluateFn} from 'puppeteer';
import {ElementHandle, EvaluateFunc} from 'puppeteer';
import Browser from "../chromium/browser.js";
import BrowserPageHandler from "../handler/browserPageHandler.js";
import CheckResult from "../outcome/checkResult.js";
import WrongAnswer from "../exception/outcome/WrongAnswer.js";
import TestPassed from "../exception/outcome/TestPassed.js";
import Element from "./element.js";
import EventHandler from "../handler/eventHandler.js";
import * as puppeteer from 'puppeteer';

class Page {
class Page{
url: string;
browser: Browser;
isOpened: boolean;
Expand Down Expand Up @@ -44,7 +45,7 @@ class Page {
execute(func: NoArgsFunction): NoArgsFunction {
return async () => {
await this.open();
const result = await this.pageInstance.evaluate(func as EvaluateFn);
const result = await this.pageInstance.evaluate(func as EvaluateFunc<any>);
return CheckResult.fromJson(result);
};
}
Expand All @@ -61,7 +62,7 @@ class Page {

async evaluate(func: NoArgsFunction): Promise<object> {
await this.open();
const evaluationResult = await this.pageInstance.evaluate(func as EvaluateFn);
const evaluationResult = await this.pageInstance.evaluate(func as EvaluateFunc<any>);
if (CheckResult.isCheckResult(evaluationResult)) {
if (!evaluationResult.isCorrect) {
throw new WrongAnswer(evaluationResult.feedback);
Expand All @@ -82,6 +83,11 @@ class Page {
);
}

async getClient(): Promise<puppeteer.Page> {
await this.open();
return this.pageInstance;
}

async findById(id: string): Promise<Element | null> {
return await (await this._getBodyTag()).findById(id);
}
Expand Down
51 changes: 0 additions & 51 deletions hstest/stage/checkerLibraryVersion.ts

This file was deleted.

9 changes: 1 addition & 8 deletions hstest/stage/stageTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,15 @@ import Outcome from "../outcome/outcome.js";
import OutcomeFactory from "../outcome/outcomeFactory.js";
import WrongAnswer from "../exception/outcome/WrongAnswer.js";
import UnexpectedErrorOutcome from "../outcome/unexpectedErrorOutcome.js";
import CheckerLibraryVersion from "./checkerLibraryVersion";
import puppeteer from "puppeteer";
import * as puppeteer from 'puppeteer';

class StageTest {

node: NodeEnvironment = new NodeEnvironment();
runner: TestRunner = new JsRunner();
tests: NoArgsFunction[] = [];

checkerLibraryVersion: CheckerLibraryVersion = new CheckerLibraryVersion();

constructor() {
// Perform the library version check upon class instantiation
this.checkerLibraryVersion.checkLibraryVersion().catch((error) => {
console.error("Error while checking library version:", error);
});
}

getPage(url: string, options: puppeteer.WaitForOptions = {}): Page {
Expand Down
Loading