Skip to content

Commit

Permalink
docs(cli): expand exported function documentation for the cli (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkdev98 authored Feb 18, 2021
1 parent f49e3ce commit 449d45d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 6 deletions.
1 change: 0 additions & 1 deletion packages/cli/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export { collectScripts } from "./src/utils.js";
export { test, mainTestFn } from "./src/testing/index.js";
export { bench, mainBenchFn } from "./src/benchmarking/index.js";
6 changes: 6 additions & 0 deletions packages/cli/src/benchmarking/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ export async function runBenchmarks(state) {
}

/**
* Benchmark entry point. The benchmark runner will wait a bit till now new benchmarks
* are registered and then start execution.
*
* @since 0.1.0
*
* @param {string} name
* @param {BenchCallback} callback
* @returns {undefined}
*/
export function bench(name, callback) {
state.push({ name, callback });
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/src/benchmarking/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ import {
} from "./state.js";

/**
* Wraps `mainFn` and `areBenchRunning
* Wraps `mainFn` and starts the benchmark runner if not already started.
* By calling this in your bench files, it allows the benchmark file to be directly executed
* via `node file.bench.js`. When the runner is already active, this function will be a no
* op.
*
* @since 0.1.0
*
* @param {ImportMeta} meta
* @returns {undefined}
*/
export function mainBenchFn(meta) {
if (areBenchRunning) {
Expand Down
9 changes: 7 additions & 2 deletions packages/cli/src/testing/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@ export async function runTestsRecursively(testState) {
}

/**
* Register top-level tests. The main entry point of the test runner
*
* @since 0.1.0
* @function
* @param {string} name
* @param {TestCallback} callback
*
* @param {string} name The test name
* @param {TestCallback} callback The function that is executed by the test runner. This
* can do async setup, register child tests and run assertions
* @returns {undefined}
*/
export const test = subTest.bind(undefined, state);
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/src/testing/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ import {
} from "./state.js";

/**
* Wraps `mainFn` and `areTestsRunning`
* Wraps `mainFn` and starts the test runner if not already started.
* By calling this in your test files, it allows the test file to be directly executed
* via `node file.test.js`. When the runner is already active, this function will be a no
* op.
*
* @since 0.1.0
*
* @param {ImportMeta} meta
* @returns {undefined}
*/
export function mainTestFn(meta) {
if (areTestsRunning) {
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import chokidar from "chokidar";
import treeKill from "tree-kill";

/**
* Load scripts directory and package.json scripts
* Load scripts directory and package.json scripts.
*
* @returns {ScriptCollection}
*/
export function collectScripts() {
Expand Down

0 comments on commit 449d45d

Please sign in to comment.