Skip to content
/ xbell Public

A powerful and easy-to-use test framework for writing unit and end-to-end tests in JavaScript.

License

Notifications You must be signed in to change notification settings

x-bell/xbell

Repository files navigation

xbell

XBell

GitHub license npm version resolution

A powerful test framework.

Documentation | Getting Started

Installation

npm install xbell

To install the browser module, run the following command:

npx xbell install browser

Unit Testing

Testing in Node.js

Here's an example of how to use XBell to test your code in Node.js:

import { test } from 'xbell';

test('test code in nodejs', ({ expect }) => {
  const { add } = await import('./add');
  const result = add(1, 1);
  expect(result).toBe(2);
});

Testing in the Browser

Here's an example of how to use XBell to test your code in the browser:

test.browser('test code in browser', ({ expect, page }) => {
  const { add } = await import('./add');
  const result = add(1, 1);
  expect(result).toBe(2);

  window.document.body.innerHTML = result;
  await expect(page).toMatchScreenshot({
    name: 'default-screenshot',
  });
});

End-to-End Testing

Here's an example of how to use XBell to perform end-to-end testing:

test('e2e testing', ({ page, expect }) => {
  await page.goto('https://example.com');
  await expect(page).toMatchScreenshot({
    name: 'default-screenshot',
  });
});

License

XBell is MIT licensed.