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

feat: add test helper #71

Merged
merged 1 commit into from
Mar 4, 2024
Merged

feat: add test helper #71

merged 1 commit into from
Mar 4, 2024

Conversation

wellwelwel
Copy link
Owner

test

test(() => void)

test is a helper to assist you in such cases:

  • Use the beforeEach and afterEach for each test performed
  • Isolate or group your tests in the same file
import { test, beforeEach, afterEach } from 'poku';

const prepareService = () => true;
const resetService = () => true;

beforeEach(() => prepareService(), {
  assert: false,
});

afterEach(() => resetService(), {
  assert: false,
});

test(() => {
  // do anything you want
});

test(() => {
  // do anything you want
});

⚠️ Ensure you disabled the assert on beforeEach and afterEach options.

By using promises

import { test, beforeEach, afterEach } from 'poku';

const prepareService = () =>
  new Promise((resolve) => resolve(true), {
    assert: false,
  });

const resetService = () =>
  new Promise((resolve) => resolve(true), {
    assert: false,
  });

beforeEach(async () => await prepareService());
afterEach(async () => await resetService());

await test(async () => {
  // do anything you want
});

await test(async () => {
  // do anything you want
});

Copy link

codecov bot commented Mar 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (dc7b951) to head (af943bb).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #71   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        26    +1     
  Lines           25        26    +1     
=========================================
+ Hits            25        26    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wellwelwel wellwelwel merged commit a4ea046 into main Mar 4, 2024
28 checks passed
@wellwelwel wellwelwel deleted the test-helper branch March 6, 2024 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant