UNPKG

@palmares/tests

Version:

This defines a default test framework testing stuff inside of the framework

172 lines (170 loc) 5.34 kB
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // src/adapter/functions.ts 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"); } }; export { TestFunctionsAdapter, testFunctionsAdapter };