Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

ctrf

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ctrf - npm Package Compare versions

Comparing version
0.0.16
to
0.0.17
+9
-2
package.json
{
"name": "ctrf",
"version": "0.0.16",
"version": "0.0.17",
"description": "Common library for working with CTRF reports",

@@ -36,3 +36,10 @@ "type": "module",

],
"repository": "github:ctrf-io/ctrf-core-js",
"repository": {
"type": "git",
"url": "git+https://github.com/ctrf-io/ctrf-core-js.git"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"homepage": "https://ctrf.io",

@@ -39,0 +46,0 @@ "author": "Matthew Thomas",

-14
/**
* CTRF framework-agnostic facade functions
* These functions call into the global runtime that's set by framework-specific packages
* Simplified API focusing on test.extra enrichment
*/
/**
* Test-related CTRF functions
*/
export declare const test: {
/**
* Add extra metadata to a test
*/
addExtra: (key: string, value: unknown) => Promise<void>;
};
/**
* CTRF framework-agnostic facade functions
* These functions call into the global runtime that's set by framework-specific packages
* Simplified API focusing on test.extra enrichment
*/
import { getGlobalCtrfRuntimeWithAutoconfig } from './runtime.js';
const callRuntimeMethod = (method, ...args) => {
const runtime = getGlobalCtrfRuntimeWithAutoconfig();
if (runtime && typeof runtime.then !== 'function') {
// @ts-ignore
return runtime[method](...args);
}
return runtime.then((ctrfRuntime) => {
// @ts-ignore
return ctrfRuntime[method](...args);
});
};
/**
* Test-related CTRF functions
*/
export const test = {
/**
* Add extra metadata to a test
*/
addExtra: (key, value) => {
return callRuntimeMethod('addExtra', key, value);
}
};
export type { CtrfRuntime } from './runtime.js';
export { setGlobalCtrfRuntime, getGlobalCtrfRuntime, getGlobalCtrfRuntimeWithAutoconfig } from './runtime.js';
export { test } from './facade.js';
export { setGlobalCtrfRuntime, getGlobalCtrfRuntime, getGlobalCtrfRuntimeWithAutoconfig } from './runtime.js';
export { test } from './facade.js';
/**
* CTRF runtime system
*/
/**
* Interface that framework-specific runtimes must implement
*/
export interface CtrfRuntime {
addExtra(key: string, value: unknown): Promise<void>;
}
/**
* Set the global CTRF runtime (called by framework-specific packages)
*/
export declare const setGlobalCtrfRuntime: (runtime: CtrfRuntime) => void;
/**
* Get the current global CTRF runtime
*/
export declare const getGlobalCtrfRuntime: () => CtrfRuntime;
/**
* Get the global CTRF runtime with auto-configuration attempt
* This tries to auto-detect and configure framework-specific runtimes
*/
export declare const getGlobalCtrfRuntimeWithAutoconfig: () => CtrfRuntime | Promise<CtrfRuntime>;
export { test } from './facade.js';
/**
* CTRF runtime system
*/
/**
* No-op runtime that logs warnings when no framework runtime is available
*/
class NoopCtrfRuntime {
warn(method) {
console.warn(`CTRF: ${method} called but no framework runtime is available. Make sure you have configured a CTRF reporter for your test framework.`);
}
async addExtra() {
this.warn('addExtra');
}
}
const CTRF_RUNTIME_KEY = 'ctrfRuntime';
const noopRuntime = new NoopCtrfRuntime();
/**
* Set the global CTRF runtime (called by framework-specific packages)
*/
export const setGlobalCtrfRuntime = (runtime) => {
;
globalThis[CTRF_RUNTIME_KEY] = runtime;
};
/**
* Get the current global CTRF runtime
*/
export const getGlobalCtrfRuntime = () => {
const runtime = globalThis?.[CTRF_RUNTIME_KEY];
return runtime ?? noopRuntime;
};
/**
* Get the global CTRF runtime with auto-configuration attempt
* This tries to auto-detect and configure framework-specific runtimes
*/
export const getGlobalCtrfRuntimeWithAutoconfig = () => {
const runtime = getGlobalCtrfRuntime();
if (runtime !== noopRuntime) {
return runtime;
}
// protection from bundlers tree-shaking visiting (webpack, rollup)
const pwAutoconfigModuleName = 'playwright-ctrf-json-reporter/autoconfig';
return import(pwAutoconfigModuleName)
.then(() => {
return getGlobalCtrfRuntime();
})
.catch(() => {
return noopRuntime;
});
};
// Export facade functions (framework-agnostic API)
export { test } from './facade.js';