kizu 3.6.7 → 3.7.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 CHANGED
@@ -7,9 +7,9 @@
7
7
  [![build status](https://github.com/mhweiner/kizu/actions/workflows/release.yml/badge.svg)](https://github.com/mhweiner/kizu/actions)
8
8
  [![SemVer](https://img.shields.io/badge/SemVer-2.0.0-blue)]()
9
9
  [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
10
- [![AutoRel](https://img.shields.io/badge/v2-AutoRel?label=AutoRel&labelColor=0ab5fc&color=grey&link=https%3A%2F%2Fgithub.com%2Fmhweiner%2Fautorel)](https://github.com/mhweiner/autorel)
10
+ [![AutoRel](https://img.shields.io/badge/%F0%9F%9A%80%20AutoRel-2D4DDE)](https://github.com/mhweiner/autorel)
11
11
 
12
- **kizu** is a fast, minimalist test runner for TypeScript and JavaScript, with a small, easy-to-learn API that lets you focus on your tests — not your tooling.
12
+ Kizu is a fast, minimalist test runner for TypeScript and JavaScript, with a small, easy-to-learn API that lets you focus on your tests — not your tooling.
13
13
 
14
14
  Designed to help you write simple, readable, and maintainable tests.
15
15
 
package/bin/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ts-node
2
2
 
3
- require('../dist/run');
3
+ require('../dist/cli');
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const commander_1 = require("commander");
4
+ const run_1 = require("./run");
5
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
6
+ const packageJson = require('../package.json');
7
+ const program = new commander_1.Command();
8
+ program
9
+ .name('kizu')
10
+ .version(packageJson.version, '-v, --version')
11
+ .description('⚫️ kizu\n\nAn easy-to-use, fast, and defensive Typescript/Javascript test runner designed to help you to write simple, readable, and maintainable tests.')
12
+ .option('--fail-only, -f', 'Only show failures in the output.', false)
13
+ .argument('<glob>', 'Glob pattern to match files to run tests on.')
14
+ .parse(process.argv);
15
+ const flags = program.opts();
16
+ const filesGlob = program.args[0];
17
+ (0, run_1.run)(flags, filesGlob).catch(console.log.bind(console));
18
+ //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- export declare function getSpecFiles(): Promise<string[]>;
1
+ export declare function getSpecFiles(arg: string): Promise<string[]>;
@@ -14,9 +14,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.getSpecFiles = getSpecFiles;
16
16
  const tiny_glob_1 = __importDefault(require("tiny-glob"));
17
- function getSpecFiles() {
17
+ function getSpecFiles(arg) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
- return (0, tiny_glob_1.default)(process.argv[2]);
19
+ return (0, tiny_glob_1.default)(arg);
20
20
  });
21
21
  }
22
22
  //# sourceMappingURL=getSpecFiles.js.map
package/dist/output.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TestResultsByFile, FinalResults } from './run';
2
2
  import { TestResults } from './test';
3
- export declare function printResultsByFile(resultsByFile: TestResultsByFile): void;
4
- export declare function printFileResults(filename: string, tests: TestResults[]): void;
3
+ export declare function printResultsByFile(resultsByFile: TestResultsByFile, showOnlyFailures?: boolean): void;
4
+ export declare function printFileResults(filename: string, tests: TestResults[], showOnlyFailures?: boolean): void;
5
5
  export declare function printSummary(finalResults: FinalResults): void;
package/dist/output.js CHANGED
@@ -21,19 +21,25 @@ The following spec files do not have any attempted or completed tests:
21
21
 
22
22
  ${files.join(', ')}
23
23
  `);
24
- function printResultsByFile(resultsByFile) {
24
+ function printResultsByFile(resultsByFile, showOnlyFailures = false) {
25
25
  const sortedResults = (0, sortTestResults_1.sortTestResults)(resultsByFile);
26
26
  for (const [filename, tests] of sortedResults) {
27
- printFileResults(filename, tests);
27
+ printFileResults(filename, tests, showOnlyFailures);
28
28
  }
29
29
  }
30
- function printFileResults(filename, tests) {
31
- const doesFileHaveFailures = tests.some((test) => !(0, isTestPassing_1.isTestPassing)(test));
32
- const header = `${kleur_1.default.underline().blue(filename)} ${doesFileHaveFailures ? failureSymbol : successSymbol}\n`;
30
+ function printFileResults(filename, tests, showOnlyFailures = false) {
31
+ const hasFailure = tests.some((test) => !(0, isTestPassing_1.isTestPassing)(test));
32
+ if (showOnlyFailures && !hasFailure)
33
+ return;
34
+ const header = `${kleur_1.default.underline().blue(filename)} ${hasFailure ? failureSymbol : successSymbol}\n`;
33
35
  log(header);
34
36
  tests.forEach(((test) => {
37
+ if (showOnlyFailures && (0, isTestPassing_1.isTestPassing)(test))
38
+ return;
35
39
  log(`${test.description} ${(0, isTestPassing_1.isTestPassing)(test) ? successSymbol : failureSymbol}`);
36
40
  test.assertions.forEach((assertion) => {
41
+ if (showOnlyFailures && assertion.pass)
42
+ return;
37
43
  log(kleur_1.default.gray(` ${assertion.description} ${assertion.pass ? successSymbol : failureSymbol}`));
38
44
  !assertion.pass && printFailedAssertionDiag(assertion);
39
45
  });
package/dist/run.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import { TestResults } from './test';
2
+ export type Flags = {
3
+ failOnly: boolean;
4
+ };
2
5
  export type TestResultsByFile = {
3
6
  [file: string]: TestResults[];
4
7
  };
@@ -10,3 +13,4 @@ export type FinalResults = {
10
13
  numAssertions: number;
11
14
  numSuccessfulAssertions: number;
12
15
  };
16
+ export declare function run(flags: Flags, filesGlob: string): Promise<void>;
package/dist/run.js CHANGED
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.run = run;
15
16
  const ora_1 = __importDefault(require("ora"));
16
17
  const output_1 = require("./output");
17
18
  const calculateFinalResults_1 = require("./calculateFinalResults");
@@ -21,13 +22,13 @@ const getSpecFiles_1 = require("./getSpecFiles");
21
22
  const testResultsByFile = {};
22
23
  let numCompletedTests = 0;
23
24
  const status = (0, ora_1.default)();
24
- function start() {
25
+ function run(flags, filesGlob) {
25
26
  return __awaiter(this, void 0, void 0, function* () {
26
- const specFiles = yield (0, getSpecFiles_1.getSpecFiles)();
27
+ const specFiles = yield (0, getSpecFiles_1.getSpecFiles)(filesGlob);
27
28
  console.log(`Found ${specFiles.length} spec files.\n`);
28
29
  status.start('Running tests...');
29
30
  yield (0, workerPool_1.workerPool)(specFiles, addTestResults);
30
- finish(specFiles);
31
+ showResults(flags, specFiles);
31
32
  });
32
33
  }
33
34
  /**
@@ -40,13 +41,12 @@ function addTestResults(file, results) {
40
41
  testResultsByFile[file] = (testResultsByFile[file] || []).concat([results]);
41
42
  status.text = `${numCompletedTests} tests completed.`;
42
43
  }
43
- function finish(specFiles) {
44
+ function showResults(flags, specFiles) {
44
45
  status.stop();
45
46
  const finalResults = (0, calculateFinalResults_1.calculateFinalResults)(specFiles, testResultsByFile);
46
- (0, output_1.printResultsByFile)(testResultsByFile);
47
+ (0, output_1.printResultsByFile)(testResultsByFile, flags.failOnly);
47
48
  (0, output_1.printSummary)(finalResults);
48
49
  if ((0, shouldExitWithError_1.shouldExitWithError)(finalResults))
49
50
  process.exit(1);
50
51
  }
51
- start().catch(console.log.bind(console));
52
52
  //# sourceMappingURL=run.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kizu",
3
- "version": "3.6.7",
3
+ "version": "3.7.0",
4
4
  "description": "An easy-to-use, fast, and defensive Typescript/Javascript test runner designed to help you to write simple, readable, and maintainable tests.",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -40,6 +40,7 @@
40
40
  "node-tap"
41
41
  ],
42
42
  "dependencies": {
43
+ "commander": "14.0.0",
43
44
  "deep-object-diff": "^1.1.0",
44
45
  "diff": "^5.0.0",
45
46
  "kleur": "^4.1.4",