Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(filter): include both .test. and .spec. as default #27

Merged
merged 3 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading