Skip to content

Commit

Permalink
fix(filter): include both .test. and .spec. as default (#27)
Browse files Browse the repository at this point in the history
* chore(website): add robots.txt

* fix(poku and CLI): include both .test. and .spec. as default filter

* chore(CLI): improve hr
  • Loading branch information
wellwelwel authored Feb 24, 2024
1 parent f570b3c commit 9172160
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
10 changes: 9 additions & 1 deletion goals.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
- **fix:** include both .test. and .spec. as default filter
# Goals

## `fix:`

---

## `feat:`

- **feat:** show message from `assert` like in popular "describe" and "it" if `describe` option is `true`
- **feat:** show individual test execution time
- **feat:** allow to limit concurrency in parallel runs
3 changes: 3 additions & 0 deletions src/helpers/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ export const format = {
success: (value: string) => `\x1b[32m${value}\x1b[0m`,
fail: (value: string) => `\x1b[31m${value}\x1b[0m`,
};

export const getLargestStringLength = (arr: string[]): number =>
arr.reduce((max, current) => Math.max(max, current.length), 0);
19 changes: 15 additions & 4 deletions src/helpers/hr.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { EOL } from 'node:os';
import process from 'node:process';

export const hr = () => {
const columns = process.stdout.columns;
const line = '⎯'.repeat(columns - 10 || 30);
let lastLenght: number = 0;

console.log(`\x1b[2m${line}\x1b[0m${EOL}`);
export const hr = (size?: number) => {
const pad = 10;
const limit = process.stdout.columns - pad;
const fileLenght = typeof size === 'number' ? Math.floor(size / 2) + pad : 0;
const columns =
fileLenght > 0 && fileLenght <= limit
? fileLenght
: lastLenght > 0
? lastLenght
: limit;
const line = '⎯'.repeat(columns);
lastLenght = columns;

console.log(`${EOL}\x1b[2m${line}\x1b[0m${EOL}`);
};
2 changes: 1 addition & 1 deletion src/modules/list-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const listFiles = (
configs?: Configs
) => {
const currentFiles = fs.readdirSync(dirPath);
const defaultRegExp = /\.test\./i;
const defaultRegExp = /\.(test|spec)\./i;
const filter: RegExp =
(envFilter
? envFilter
Expand Down
4 changes: 2 additions & 2 deletions src/services/run-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runner } from '../helpers/runner.js';
import { indentation } from '../helpers/indentation.js';
import { listFiles } from '../modules/list-files.js';
import { hr } from '../helpers/hr.js';
import { format } from '../helpers/format.js';
import { format, getLargestStringLength } from '../helpers/format.js';
import { runTestFile } from './run-test-file.js';
import { Configs } from '../@types/poku.js';
import { isQuiet } from '../helpers/logs.js';
Expand All @@ -24,7 +24,7 @@ export const runTests = async (
let passed = true;

if (showLogs) {
hr();
hr(getLargestStringLength(files));
console.log(
`${format.bold('Directory:')} ${format.underline(currentDir)}${EOL}`
);
Expand Down
4 changes: 4 additions & 0 deletions website/static/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-agent: *
Disallow:

Sitemap: https://poku.dev/sitemap.xml

0 comments on commit 9172160

Please sign in to comment.