@palmares/tests
Version:
This defines a default test framework testing stuff inside of the framework
196 lines (194 loc) • 6.4 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/adapter/functions.ts
var functions_exports = {};
__export(functions_exports, {
TestFunctionsAdapter: () => TestFunctionsAdapter,
testFunctionsAdapter: () => testFunctionsAdapter
});
module.exports = __toCommonJS(functions_exports);
function testFunctionsAdapter(args) {
let CustomTestFunctionsAdapter = class CustomTestFunctionsAdapter extends TestFunctionsAdapter {
static {
__name(this, "CustomTestFunctionsAdapter");
}
constructor() {
super();
this.getAfterAll = args.getAfterAll.bind(this);
this.getAfterEach = args.getAfterEach.bind(this);
this.getBeforeAll = args.getBeforeAll.bind(this);
this.getBeforeEach = args.getBeforeEach.bind(this);
this.getDescribe = args.getDescribe.bind(this);
this.getTest = args.getTest.bind(this);
}
getDescribe = args.getDescribe;
getTest = args.getTest;
getBeforeEach = args.getBeforeEach;
getAfterEach = args.getAfterEach;
getBeforeAll = args.getBeforeAll;
getAfterAll = args.getAfterAll;
};
return CustomTestFunctionsAdapter;
}
__name(testFunctionsAdapter, "testFunctionsAdapter");
var TestFunctionsAdapter = class {
static {
__name(this, "TestFunctionsAdapter");
}
/**
* Should run a callback inside a describe function from your test framework.
*
* @example
* ```typescript
* import { TestFunctionsAdapter } from '@palmares/tests';
*
* export default class JestTestFunctionsAdapter extends TestFunctionsAdapter {
* getDescribe(descriptionName: string, callback: () => void): void {
* const describe = require('@jest/globals').describe;
* describe(descriptionName, () => {
* callback();
* });
* }
* }
* ```
*
* @param descriptionName - The name of the description
* @param callback - The callback that should be called inside the describe function
*/
getDescribe(_descriptionName, _callback, _customData) {
throw new Error("Not implemented");
}
/**
* Should run a async callback function inside a `test` or `it` function from your test framework.
*
* @example
* ```typescript
* import { TestFunctionsAdapter } from '@palmares/tests';
*
* export default class JestTestFunctionsAdapter extends TestFunctionsAdapter {
* getTest(descriptionName: string, callback: () => Promise<void>): void {
* const test = require('@jest/globals').test;
* test(descriptionName, async () => {
* await callback();
* });
* }
* }
* ```
*
* @param testName - The name of the test
* @param callback - The callback that should be called inside the test function
*/
getTest(_testName, _callback, _customData) {
throw new Error("Not implemented");
}
/**
* Should run a callback inside a beforeEach function from your test framework.
*
* @example
* ```typescript
* import { TestFunctionsAdapter } from '@palmares/tests';
*
* export default class JestTestFunctionsAdapter extends TestFunctionsAdapter {
* getBeforeEach(callback: () => Promise<void>): void {
* const beforeEach = require('@jest/globals').beforeEach;
* beforeEach(async () => {
* await callback();
* });
* }
* }
* ```
*
* @param callback - The callback that should be called inside the beforeEach function
*/
getBeforeEach(_callback, _customData) {
throw new Error("Not implemented");
}
/**
* Should run a callback inside a afterEach function from your test framework.
*
* @example
* ```typescript
* import { TestFunctionsAdapter } from '@palmares/tests';
*
* export default class JestTestFunctionsAdapter extends TestFunctionsAdapter {
* getAfterEach(callback: () => Promise<void>): void {
* const afterEach = require('@jest/globals').afterEach;
* afterEach(async () => {
* await callback();
* });
* }
* }
* ```
*
* @param callback - The callback that should be called inside the beforeEach function
*/
getAfterEach(_callback, _customData) {
throw new Error("Not implemented");
}
/**
* Should run a callback inside a beforeAll function from your test framework.
*
* @example
* ```typescript
* import { TestFunctionsAdapter } from '@palmares/tests';
*
* export default class JestTestFunctionsAdapter extends TestFunctionsAdapter {
* getBeforeAll(callback: () => Promise<void>): void {
* const beforeAll = require('@jest/globals').beforeAll;
* beforeAll(async () => {
* await callback();
* });
* }
* }
* ```
*
* @param callback - The callback that should be called inside the beforeEach function
*/
getBeforeAll(_callback, _customData) {
throw new Error("Not implemented");
}
/**
* Should run a callback inside an afterAll function from your test framework.
*
* @example
* ```typescript
* import { TestFunctionsAdapter } from '@palmares/tests';
*
* export default class JestTestFunctionsAdapter extends TestFunctionsAdapter {
* getAfterAll(callback: () => Promise<void>): void {
* const afterAll = require('@jest/globals').afterAll;
* afterAll(async () => {
* await callback();
* });
* }
* }
* ```
*
* @param callback - The callback that should be called inside the beforeEach function
*/
getAfterAll(_callback, _customData) {
throw new Error("Not implemented");
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TestFunctionsAdapter,
testFunctionsAdapter
});