UNPKG

testplane

Version:

Tests framework based on mocha and wdio

69 lines (68 loc) 4.1 kB
import { type EncodedSourceMap } from "@jridgewell/trace-mapping"; import type { CDPRuntime } from "../domains/runtime"; import type { CDPScriptCoverage, CDPSessionId } from "../types"; import type { HashFileContents, NormalizedDependencies, SelectivityCompressionType, TestDependenciesFileContents } from "./types"; import type { Test } from "../../../types"; import { SelectivityDependencyScope, SelectivityMapDependencyRelativePathFn } from "../../../config/types"; /** * Sorted list of generated-bundle segment boundaries. * Segment `i` owns generated bytes `[offset[i], offset[i + 1])` (the last segment runs to the end of the bundle) */ interface ParsedSourceMapRanges { offset: number[]; /** Can be empty if segment is glue code */ filename: string[]; } /** * Tries to fetch text by url from node.js, then falls back to "fetch" from browser, if node.js fetch fails * @param url text url * @param runtime CDP runtime domain * @param sessionId CDP session id * @returns text */ export declare const fetchTextWithBrowserFallback: (url: string, runtime: CDPRuntime, sessionId: CDPSessionId) => Promise<string>; /** * Replaces "webpack://" protocol with source path because "source-map" doesn't work well with protocol paths * @param sourceMap Raw source maps in https://tc39.es/ecma426/ format * @param sourceRoot Source root */ export declare const patchSourceMapSources: (sourceMap: EncodedSourceMap, sourceRoot?: string) => EncodedSourceMap; export declare const parseSourceMapRanges: (source: string, sourceMaps: string, sourceRoot: string) => Promise<ParsedSourceMapRanges>; /** * Given compiled code, its source map, and the executed offsets * It returns the original source files touched * Useful for turning coverage ranges into real TS/JS module dependencies * @param source Compiled source code * @param sourceMaps Source maps JSON string * @param coverages CDP script coverages * @param sourceRoot Source root */ export declare const extractSourceFilesDeps: ({ offset, filename }: ParsedSourceMapRanges, coverages: CDPScriptCoverage[], sourceFilterFn?: ((sourceFileName: string) => boolean) | undefined) => Set<string>; /** * @returns True, if fileUrlLikePath has some kind of protocol ("data://", "webpack://", "turbopack://", "file://")... */ export declare const hasProtocol: (fileUrlLikePath: string) => boolean; export declare const isDataProtocol: (fileUrlLikePath: string) => boolean; /** * @param dependencies.css set of css dependency URI's * @param dependencies.js set of js dependency URI's * @param dependencies.png set of png dependency URI's * @returns sorted uniq arrays of relative paths */ export declare const transformSourceDependencies: ({ css: cssDependencies, js: jsDependencies, png: pngDependencies, }: { css: Set<string> | null; js: Set<string> | null; png: Set<string> | null; }, mapDependencyPathFn: null | SelectivityMapDependencyRelativePathFn, scope: SelectivityDependencyScope) => NormalizedDependencies; /** Merges two sorted deps array into one with uniq values */ export declare const mergeSourceDependencies: (a: NormalizedDependencies, b: NormalizedDependencies) => NormalizedDependencies; export declare const shallowSortObject: (obj: Record<string, unknown>) => void; export declare const getSelectivityHashesPath: (testDependenciesPath: string) => string; export declare const readHashFileContents: (selectivityHashesPath: string, compression: SelectivityCompressionType) => Promise<HashFileContents>; export declare const getSelectivityTestsPath: (testDependenciesPath: string) => string; export declare const getTestSelectivityDumpId: (test: Test) => string; export declare const getTestDependenciesPath: (selectivityTestsPath: string, test: Test) => string; /** @returns `Promise<Record<BrowserID, Record<DepType, NormalizedDependencies>>>` */ export declare const readTestDependencies: (selectivityTestsPath: string, test: Test, compression: SelectivityCompressionType) => Promise<TestDependenciesFileContents>; export declare const isCachedOnFs: (value: unknown) => value is true; export {};