Skip to content

Commit

Permalink
refactor(test-kit): make imports esm compatible (#1960)
Browse files Browse the repository at this point in the history
also added missing ref to test/tsconfig.json
  • Loading branch information
AviVahl authored Aug 8, 2023
1 parent 6693b43 commit 0d4850e
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 49 deletions.
8 changes: 4 additions & 4 deletions packages/test-kit/src/forked-process-application.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PerformanceMetrics, ProcessMessageId, isProcessMessage } from '@wixc3/engine-runtime-node';
import type { IFeatureTarget, IPortMessage, IFeatureMessagePayload } from '@wixc3/engine-scripts';
import { ChildProcess, fork } from 'child_process';
import type { IExecutableApplication } from './types';
import { isProcessMessage, type PerformanceMetrics, type ProcessMessageId } from '@wixc3/engine-runtime-node';
import type { IFeatureMessagePayload, IFeatureTarget, IPortMessage } from '@wixc3/engine-scripts';
import { ChildProcess, fork } from 'node:child_process';
import type { IExecutableApplication } from './types.js';

export class ForkedProcessApplication implements IExecutableApplication {
private engineStartProcess: ChildProcess | undefined;
Expand Down
16 changes: 8 additions & 8 deletions packages/test-kit/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export * from './create-browser-provider';
export * from './remote-http-application';
export * from './forked-process-application';
export * from './run-environment';
export * from './types';
export * from './with-feature';
export * from './with-local-fixture';
export * from './normalize-test-name';
export * from './create-browser-provider.js';
export * from './remote-http-application.js';
export * from './forked-process-application.js';
export * from './run-environment.js';
export * from './types.js';
export * from './with-feature.js';
export * from './with-local-fixture.js';
export * from './normalize-test-name.js';
10 changes: 5 additions & 5 deletions packages/test-kit/src/remote-http-application.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { request } from 'http';
import { posix } from 'path';
import type { IFeatureTarget, IFeatureMessagePayload } from '@wixc3/engine-scripts';
import type { IExecutableApplication } from './types';
import type { PerformanceMetrics, IProcessMessage } from '@wixc3/engine-runtime-node';
import type { IProcessMessage, PerformanceMetrics } from '@wixc3/engine-runtime-node';
import type { IFeatureMessagePayload, IFeatureTarget } from '@wixc3/engine-scripts';
import { request } from 'node:http';
import { posix } from 'node:path';
import type { IExecutableApplication } from './types.js';

const { join } = posix;

Expand Down
21 changes: 10 additions & 11 deletions packages/test-kit/src/run-environment.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
import fs from '@file-services/node';
import { nodeFs as fs } from '@file-services/node';
import {
AnyEnvironment,
BaseHost,
COM,
Communication,
Environment,
FeatureClass,
Running,
RuntimeEngine,
TopLevelConfig,
flattenTree,
type AnyEnvironment,
type FeatureClass,
type Running,
type TopLevelConfig,
} from '@wixc3/engine-core';
import {
ENGINE_ROOT_ENVIRONMENT_ID,
METADATA_PROVIDER_ENV_ID,
MetadataCollectionAPI,
metadataApiToken,
runNodeEnvironment,
IStaticFeatureDefinition,
type IStaticFeatureDefinition,
type MetadataCollectionAPI,
} from '@wixc3/engine-runtime-node';

import {
ENGINE_CONFIG_FILE_NAME,
findFeatures,
evaluateConfig,
EngineConfig,
IFeatureDefinition,
findFeatures,
type EngineConfig,
type IFeatureDefinition,
} from '@wixc3/engine-scripts';
import { disposeAfter } from '@wixc3/testing';

Expand Down
2 changes: 1 addition & 1 deletion packages/test-kit/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './trace';
export * from './trace.js';
26 changes: 13 additions & 13 deletions packages/test-kit/src/with-feature.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import isCI from 'is-ci';
import fs from '@file-services/node';
import playwright from 'playwright-core';
import { ensureTracePath } from './utils';
import { hookPageConsole } from './hook-page-console';
import { validateBrowser } from './supported-browsers';
import { DISPOSE_OF_TEMP_DIRS } from '@wixc3/testing-node';
import { normalizeTestName } from './normalize-test-name';
import { RemoteHttpApplication } from './remote-http-application';
import { ForkedProcessApplication } from './forked-process-application';
import { createDisposalGroup, disposeAfter, mochaCtx } from '@wixc3/testing';
import { Disposables, DisposableItem, DisposableOptions } from '@wixc3/patterns';
import type { IExecutableApplication } from './types';
import { nodeFs as fs } from '@file-services/node';
import type { TopLevelConfig } from '@wixc3/engine-core';
import type { PerformanceMetrics } from '@wixc3/engine-runtime-node';
import { Disposables, type DisposableItem, type DisposableOptions } from '@wixc3/patterns';
import { createDisposalGroup, disposeAfter, mochaCtx } from '@wixc3/testing';
import { DISPOSE_OF_TEMP_DIRS } from '@wixc3/testing-node';
import isCI from 'is-ci';
import playwright from 'playwright-core';
import { ForkedProcessApplication } from './forked-process-application.js';
import { hookPageConsole } from './hook-page-console.js';
import { normalizeTestName } from './normalize-test-name.js';
import { RemoteHttpApplication } from './remote-http-application.js';
import { validateBrowser } from './supported-browsers.js';
import type { IExecutableApplication } from './types.js';
import { ensureTracePath } from './utils/index.js';

const cliEntry = require.resolve('@wixc3/engineer/bin/engineer');

Expand Down
6 changes: 3 additions & 3 deletions packages/test-kit/src/with-local-fixture.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { spawnSync, SpawnSyncOptions } from 'child_process';
import fs from '@file-services/node';
import { IFeatureExecutionOptions, IWithFeatureOptions, withFeature } from './with-feature';
import { nodeFs as fs } from '@file-services/node';
import { createTestDir } from '@wixc3/testing-node';
import { spawnSync, type SpawnSyncOptions } from 'node:child_process';
import { withFeature, type IFeatureExecutionOptions, type IWithFeatureOptions } from './with-feature.js';

export interface IWithLocalFixtureOptions extends IWithFeatureOptions {
fixturePath?: string;
Expand Down
8 changes: 4 additions & 4 deletions packages/test-kit/test/run-environment.unit.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect } from 'chai';
import fs from '@file-services/node';
import workerThreadFeature, { serverEnv } from '@fixture/worker-thread/dist/worker-thread.feature.js';
import { getRunningFeature } from '@wixc3/engine-test-kit';
import workerThreadFeature, { serverEnv } from '@fixture/worker-thread/dist/worker-thread.feature';
import { expect } from 'chai';
import path from 'node:path';

const featurePath = fs.dirname(require.resolve('@fixture/worker-thread/package.json'));
const featurePath = path.dirname(require.resolve('@fixture/worker-thread/package.json'));

describe('runs environment', () => {
it('runs environment with workerthread support', async () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/test-kit/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"references": [
{
"path": "../src"
},
{
"path": "../../../test-fixtures/worker-thread/src"
}
]
}

0 comments on commit 0d4850e

Please sign in to comment.