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

WAT-4235: Align plugin-selenium-driver with WebDriver protocol & improve e2e-test-app #256

Merged
merged 25 commits into from
Feb 18, 2025
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
10 changes: 10 additions & 0 deletions .c8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"reporter": ["html"],
"reports-dir": "./c8-cov",
"all": true,
"include": [
"packages/plugin-selenium-driver/*/plugin/index.*",
"packages/web-application/*/web-client.*",
"packages/web-application/*/web-application.*"
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
packages/**/dist
packages/**/chrome-cache
packages/**/node_modules

core/**/dist
Expand Down
2 changes: 1 addition & 1 deletion core/api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
2 changes: 1 addition & 1 deletion core/async-assert/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
2 changes: 1 addition & 1 deletion core/async-breakpoints/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
2 changes: 1 addition & 1 deletion core/child-process/src/fork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const PREFERRED_DEBUG_PORTS: Array<number> = [
const IS_WIN = process.platform === 'win32';
const EMPTY_PARAMETERS = [];
const REQUIRE_TS_NODE = ['-r', 'ts-node/register'];
const Module = require("module").Module;
const Module = require('module').Module;

const DEFAULT_FORK_OPTIONS: IChildProcessForkOptions = {
debug: false,
Expand Down
1 change: 1 addition & 0 deletions core/child-process/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export {spawn} from './spawn';
export {spawnWithPipes} from './spawn-with-pipes';
export {fork} from './fork';
export {isChildProcess} from './utils';
18 changes: 18 additions & 0 deletions core/child-process/src/spawn-with-pipes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as childProcess from 'child_process';
import * as process from 'process';

export function spawnWithPipes(
command: string,
args: Array<string> = [],
): childProcess.ChildProcess {
const child = childProcess.spawn(command, args, {
stdio: ['pipe', 'pipe', 'pipe'], // Use pipes for proper control
cwd: process.cwd(),
detached: false, // Run attached to prevent orphan processes
});

// Ensure child does not keep the event loop active
child.unref();

return child;
}
2 changes: 1 addition & 1 deletion core/child-process/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
2 changes: 1 addition & 1 deletion core/cli-config/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
1 change: 0 additions & 1 deletion core/cli/src/commands/runCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class RunCommand implements ICLICommand {
}

async execute() {

const testWorker = new TestWorker(this.transport, {
waitForRelease: false,
localWorker: this.config.workerLimit === 'local',
Expand Down
2 changes: 1 addition & 1 deletion core/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
17 changes: 9 additions & 8 deletions core/dependencies-builder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
DependencyFileReader,
} from '@testring/types';
import {resolveAbsolutePath} from './absolute-path-resolver';
import * as path from 'node:path';

function getDependencies(absolutePath: string, content: string): Array<string> {
const requests: Array<string> = [];
Expand All @@ -21,14 +22,14 @@ function getDependencies(absolutePath: string, content: string): Array<string> {
});

traverse(sourceAST, {
CallExpression(path: NodePath<CallExpression>) {
const callee = path.get('callee') as NodePath<Identifier>;
CallExpression(nodePath: NodePath<CallExpression>) {
const callee = nodePath.get('callee') as NodePath<Identifier>;

if (callee.node.name !== 'require') {
return;
}

const args = path.get('arguments');
const args = nodePath.get('arguments');
const firstArgument = args[0];
const dependencyPath: NodePath<string> = firstArgument.get(
'value',
Expand All @@ -42,24 +43,24 @@ function getDependencies(absolutePath: string, content: string): Array<string> {
}

function createTreeNode(
path: string,
nodePath: string,
content: string,
nodes: IDependencyDictionary<IDependencyTreeNode> | null,
): IDependencyTreeNode {
return {
content,
path,
path: nodePath,
nodes,
};
}

function createDictionaryNode(
path: string,
nodePath: string,
content: string,
): IDependencyDictionaryNode {
return {
content,
path,
path: nodePath,
};
}

Expand Down Expand Up @@ -103,7 +104,7 @@ async function buildNodes(
dependencyAbsolutePath.includes('node_modules') ||
// Fix for local e2e tests running (lerna makes symlink and resolver eats it as path for real file)
// require 'node_modules/testring' = require 'packages/testring/dist'
dependencyAbsolutePath.includes('testring/dist')
dependencyAbsolutePath.includes(path.join('testring', 'dist'))
) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion core/dependencies-builder/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
4 changes: 2 additions & 2 deletions core/fs-reader/src/file-locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as fg from 'fast-glob';
import * as process from 'node:process';

export async function locateFiles(searchpath: string): Promise<string[]> {
if(!searchpath) {
if (!searchpath) {
return [];
}
if (process.platform === 'win32') {
searchpath = fg.convertPathToPattern(searchpath);
}
return await fg(searchpath, {});
}
}
3 changes: 1 addition & 2 deletions core/fs-reader/src/file-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function resolveFiles(files: Array<string>): Promise<IFile[]> {

// Limit concurrent file reads
const readFilePromises = files.map((file) =>
limit(() => readFile(file).catch(() => null))
limit(() => readFile(file).catch(() => null)),
);

const filesContent = await Promise.all(readFilePromises);
Expand All @@ -49,4 +49,3 @@ export async function resolveFiles(files: Array<string>): Promise<IFile[]> {

return compacted;
}

8 changes: 4 additions & 4 deletions core/fs-reader/test/performance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {FSReader} from '../src/fs-reader';
import * as process from 'node:process';
import * as fs from 'node:fs';

const runPerformanceTests = process.env.PERFORMANCE_TESTS === 'true' || process.argv.includes('--performance');
const runPerformanceTests =
process.env.PERFORMANCE_TESTS === 'true' ||
process.argv.includes('--performance');
const glob = path.resolve(__dirname, './fixtures/testfiles/**/**/*.test.js');

const writeTestFiles = async (count: number) => {
Expand All @@ -28,11 +30,10 @@ const removeTestFiles = async () => {
const dir = path.resolve(__dirname, './fixtures/testfiles/performance');

if (fs.existsSync(dir)) {
await fs.promises.rm(dir, { recursive: true, force: true });
await fs.promises.rm(dir, {recursive: true, force: true});
}
};


describe('Performance', function () {
this.timeout(120000);
if (!runPerformanceTests) {
Expand All @@ -41,7 +42,6 @@ describe('Performance', function () {
});
} else {
describe('FSReader', () => {

before(async () => {
await writeTestFiles(15000);
});
Expand Down
2 changes: 1 addition & 1 deletion core/fs-reader/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
5 changes: 2 additions & 3 deletions core/fs-store/src/fs-store-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ export class FSStoreClient {
delete this.reqHash[requestId];
} else {
this.reqHash[requestId].fullPath = fullPath;
this.reqHash[requestId].meta.fileName = path.basename(
fullPath,
);
this.reqHash[requestId].meta.fileName =
path.basename(fullPath);
}
}

Expand Down
6 changes: 2 additions & 4 deletions core/fs-store/src/fs-store-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ export class FSStoreServer extends PluggableModule {
private unHookCleanWorkerTransport: (() => void) | null = null;
private defaultFsPermisionPool: LockPool;

private files: Record<
string,
[FilePermissionResolver, cleanUpCBRecord]
> = {};
private files: Record<string, [FilePermissionResolver, cleanUpCBRecord]> =
{};
private inWorkRequests: Record<
string,
Record<string, [fsReqType, string]>
Expand Down
2 changes: 1 addition & 1 deletion core/fs-store/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
2 changes: 1 addition & 1 deletion core/logger/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
2 changes: 1 addition & 1 deletion core/pluggable-module/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
2 changes: 1 addition & 1 deletion core/plugin-api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
12 changes: 2 additions & 10 deletions core/sandbox/test/sandbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,8 @@ describe('Sandbox', () => {
it('should correctly pass "instanceof" check for all primitives', async () => {
const source = await fixturesFileReader('primitives.js');
const sandbox = new Sandbox(source, 'primitives.js', {});
const {
array,
map,
set,
weakMap,
weakSet,
promise,
buffer,
error,
} = sandbox.execute();
const {array, map, set, weakMap, weakSet, promise, buffer, error} =
sandbox.execute();

chai.expect(array instanceof Array).to.be.equal(true);
chai.expect(map instanceof Map).to.be.equal(true);
Expand Down
2 changes: 1 addition & 1 deletion core/sandbox/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
12 changes: 4 additions & 8 deletions core/test-run-controller/src/test-run-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const delay = (milliseconds: number) =>

export class TestRunController
extends PluggableModule
implements ITestRunController {
implements ITestRunController
{
private workers: Array<ITestWorkerInstance> = [];

private errors: Array<Error> = [];
Expand Down Expand Up @@ -189,13 +190,8 @@ export class TestRunController
private getQueueItemWithRunData(queueItem): IQueuedTest {
let screenshotsEnabled = false;
const isRetryRun = queueItem.retryCount > 0;
const {
debug,
httpThrottle,
logLevel,
devtool,
screenshotPath,
} = this.config;
const {debug, httpThrottle, logLevel, devtool, screenshotPath} =
this.config;

if (this.config.screenshots === 'enable') {
screenshotsEnabled = true;
Expand Down
2 changes: 1 addition & 1 deletion core/test-run-controller/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noEmitOnError": true,
"declaration": false,
"outDir": "dist",
"sourceMap": false,
"sourceMap": true,
"lib": [
"es5",
"es2015",
Expand Down
11 changes: 6 additions & 5 deletions core/test-worker/src/test-worker-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,12 @@ export class TestWorkerInstance implements ITestWorkerInstance {
completeHandler,
);
} else {
removeListener = this.transport.onceFrom<ITestExecutionCompleteMessage>(
this.getWorkerID(),
TestWorkerAction.executionComplete,
completeHandler,
);
removeListener =
this.transport.onceFrom<ITestExecutionCompleteMessage>(
this.getWorkerID(),
TestWorkerAction.executionComplete,
completeHandler,
);
}

this.successTestExecution = () => {
Expand Down
Loading
Loading