@aljazmc/testero 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -39
- package/bin/main.js +2284 -2010
- package/bin/types/ambient.d.ts +35 -0
- package/bin/types/collector.d.ts +3 -1
- package/bin/types/shared/config/config.d.ts +31 -0
- package/bin/types/shared/config/ignore.d.ts +5 -0
- package/bin/types/shared/config/includes.d.ts +6 -0
- package/bin/types/shared/config/index.d.ts +4 -0
- package/bin/types/shared/config/pattern.d.ts +5 -0
- package/bin/types/testero.d.ts +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** The globals of test files, for tsconfig's `types` as `@aljazmc/testero/globals`. */
|
|
2
|
+
import type { DescribeApi, TestApi } from "./collector.js";
|
|
3
|
+
import type Expect from "./expect/expect.js";
|
|
4
|
+
import type Mocks from "./mock.js";
|
|
5
|
+
import type { Body } from "./suite.js";
|
|
6
|
+
type Hook = (body: Body, timeout?: number) => void;
|
|
7
|
+
/** `testero` and `jest`, their methods return them to chain calls. */
|
|
8
|
+
interface Testero {
|
|
9
|
+
fn: typeof Mocks.fn;
|
|
10
|
+
spyOn: typeof Mocks.spyOn;
|
|
11
|
+
isMockFunction: typeof Mocks.isMockFunction;
|
|
12
|
+
clearAllMocks(): Testero;
|
|
13
|
+
resetAllMocks(): Testero;
|
|
14
|
+
restoreAllMocks(): Testero;
|
|
15
|
+
/** Sets the timeout of the tests and hooks of this file. */
|
|
16
|
+
setTimeout(timeout: number): Testero;
|
|
17
|
+
}
|
|
18
|
+
declare global {
|
|
19
|
+
const describe: DescribeApi;
|
|
20
|
+
const fdescribe: DescribeApi["only"];
|
|
21
|
+
const xdescribe: DescribeApi["skip"];
|
|
22
|
+
const test: TestApi;
|
|
23
|
+
const it: TestApi;
|
|
24
|
+
const fit: TestApi["only"];
|
|
25
|
+
const xit: TestApi["skip"];
|
|
26
|
+
const xtest: TestApi["skip"];
|
|
27
|
+
const beforeAll: Hook;
|
|
28
|
+
const afterAll: Hook;
|
|
29
|
+
const beforeEach: Hook;
|
|
30
|
+
const afterEach: Hook;
|
|
31
|
+
const expect: ReturnType<Expect["create"]>;
|
|
32
|
+
const testero: Testero;
|
|
33
|
+
const jest: Testero;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
package/bin/types/collector.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type Body, type HookKind, Suite } from "./suite.js";
|
|
2
2
|
type TestFunction = (name: string, body?: Body, timeout?: number) => void;
|
|
3
3
|
type DescribeFunction = (name: string, body: () => unknown) => void;
|
|
4
|
-
type
|
|
4
|
+
type Row = (...args: any[]) => unknown;
|
|
5
|
+
/** `each` takes a table, then declares a test or suite for each of its rows. */
|
|
6
|
+
type Table = (table: unknown, ...values: unknown[]) => (name: string, body: Row, timeout?: number) => void;
|
|
5
7
|
/** `test` and `it`, with `only`, `skip`, `todo` and `each`. */
|
|
6
8
|
export interface TestApi extends TestFunction {
|
|
7
9
|
only: TestFunction & {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Ignore from "./ignore.js";
|
|
2
|
+
export interface Options<Rules extends object = object> {
|
|
3
|
+
ignore: string[];
|
|
4
|
+
rules: Rules;
|
|
5
|
+
}
|
|
6
|
+
/** A text file found by a tool, with its path relative to the root. */
|
|
7
|
+
export interface Source {
|
|
8
|
+
file: string;
|
|
9
|
+
path: string;
|
|
10
|
+
text: string;
|
|
11
|
+
}
|
|
12
|
+
export default class Config<Rules extends object = object> {
|
|
13
|
+
#private;
|
|
14
|
+
static readonly extensions: string[];
|
|
15
|
+
readonly root: string;
|
|
16
|
+
readonly ignore: Ignore;
|
|
17
|
+
readonly rules: Rules;
|
|
18
|
+
/** What the config file set, before the defaults were merged in. */
|
|
19
|
+
readonly custom: Partial<Options<Rules>>;
|
|
20
|
+
constructor(options: Options<Rules>, root?: string, custom?: Partial<Options<Rules>>);
|
|
21
|
+
static load<Rules extends object>(name: string, defaults: Options<Rules>, root?: string): Promise<Config<Rules>>;
|
|
22
|
+
/** Handles `--config`, writing the defaults to a TypeScript config file, or with `--config js` a JavaScript one. Returns whether it was given. */
|
|
23
|
+
static init(name: string, defaults: Options, argv?: string[], root?: string): boolean;
|
|
24
|
+
/** Writes the defaults to `<name>.config.<extension>` in the root, unless a config file is there already. */
|
|
25
|
+
static export(name: string, defaults: Options, extension?: string, root?: string): string;
|
|
26
|
+
/** Deep merges plain objects, anything else in override replaces base. */
|
|
27
|
+
static merge<T>(base: T, override: unknown): T;
|
|
28
|
+
files(directory?: string): Generator<string>;
|
|
29
|
+
/** Text files that are not ignored and that accepts takes, binaries are skipped. */
|
|
30
|
+
sources(accepts?: (file: string) => boolean): Generator<Source>;
|
|
31
|
+
}
|
package/bin/types/testero.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aljazmc/testero",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A simple, Jest
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "A simple, Jest-like test runner for JavaScript, TypeScript and JSX, compiling tests with esbuild. Easy to understand, easy to customize and easy to extend.",
|
|
5
5
|
"author": "aljazmc",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"modular"
|
|
21
21
|
],
|
|
22
22
|
"engines": {
|
|
23
|
-
"node": "^22.18.0 || ^24 || ^25 || ^26"
|
|
23
|
+
"node": "^22.18.0 || ^24.2.0 || ^25 || ^26"
|
|
24
24
|
},
|
|
25
25
|
"types": "./bin/types/testero.d.ts",
|
|
26
26
|
"bin": "./bin/main.js",
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
"types": "./bin/types/testero.d.ts",
|
|
30
30
|
"default": "./bin/main.js"
|
|
31
31
|
},
|
|
32
|
+
"./globals": {
|
|
33
|
+
"types": "./bin/types/ambient.d.ts"
|
|
34
|
+
},
|
|
32
35
|
"./package.json": "./package.json"
|
|
33
36
|
},
|
|
34
37
|
"devDependencies": {
|