@babel/helper-transform-fixture-test-runner
Version:
Transform test runner for @babel/helper-fixtures module
56 lines (53 loc) • 2.04 kB
TypeScript
import { TaskOptions, Test } from '@babel/helper-fixtures';
import vm from 'node:vm';
declare function createTestContext(): vm.Context;
/**
* Run the given snippet of code inside a CommonJS module.
*
* Exposed for unit tests, not for use as an API.
*/
declare function runCodeInTestContext(code: string, opts: {
filename: string | URL;
timeout?: number;
}, context?: vm.Context): any;
type SuiteOptions = {
ignoreSuites?: string[];
ignoreTasks?: string[];
};
declare function export_default(fixturesLoc: string | URL, name: string, suiteOpts?: SuiteOptions, taskOpts?: TaskOptions, dynamicOpts?: (options: TaskOptions, task: Test) => void): void;
type ProcessTestOpts = {
args: string[];
executor?: string;
ipc?: boolean;
ipcMessage?: string;
stdout: string;
stderr: string;
stdin: string;
stdoutPath: string;
stderrPath: string;
stdoutContains?: boolean;
stderrContains?: boolean;
testLoc: string;
outFiles: Record<string, string>;
inFiles: Record<string, string>;
noBabelrc?: boolean;
minNodeVersion?: number;
env?: Record<string, string>;
BABEL_8_BREAKING?: boolean;
};
type ProcessTest = {
suiteName: string;
testName: string;
skip: boolean;
fn: Function;
opts: ProcessTestOpts;
binLoc?: string;
};
type ProcessTestBeforeHook = (test: ProcessTest, tmpDir: string) => void;
type ProcessTestAfterHook = (test: ProcessTest, tmpDir: string, stdout: string, stderr: string) => {
stdout: string;
stderr: string;
};
declare function buildParallelProcessTests(name: string, tests: ProcessTest[]): (curr: number, total: number) => void;
declare function buildProcessTests(dir: string | URL, beforeHook: ProcessTestBeforeHook, afterHook?: ProcessTestAfterHook): ProcessTest[];
export { type ProcessTest, type ProcessTestAfterHook, type ProcessTestBeforeHook, type ProcessTestOpts, type SuiteOptions, buildParallelProcessTests, buildProcessTests, createTestContext, export_default as default, runCodeInTestContext };