Top Related Projects
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Fast, easy and reliable testing for anything that runs in a browser.
JavaScript API for Chrome and Firefox
A browser automation framework and ecosystem.
Next-gen browser and mobile automation test framework for Node.js
Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
Quick Overview
Harper is a lightweight, zero-dependency JavaScript library for creating and managing state machines. It provides a simple API for defining states, transitions, and actions, making it easy to model complex application behaviors and manage state in a predictable manner.
Pros
- Simple and intuitive API for creating state machines
- Zero dependencies, making it lightweight and easy to integrate
- Supports both synchronous and asynchronous transitions
- Extensible through plugins and custom actions
Cons
- Limited documentation and examples
- Relatively new project, which may lead to potential instability or breaking changes
- Lacks some advanced features found in more established state machine libraries
Code Examples
Creating a simple state machine:
import { createMachine } from 'harper';
const trafficLight = createMachine({
initial: 'red',
states: {
red: { on: { NEXT: 'green' } },
yellow: { on: { NEXT: 'red' } },
green: { on: { NEXT: 'yellow' } },
},
});
console.log(trafficLight.state); // 'red'
trafficLight.transition('NEXT');
console.log(trafficLight.state); // 'green'
Using actions in transitions:
const counterMachine = createMachine({
initial: 'idle',
context: { count: 0 },
states: {
idle: {
on: {
INCREMENT: {
target: 'idle',
actions: (context) => context.count++,
},
},
},
},
});
counterMachine.transition('INCREMENT');
console.log(counterMachine.context.count); // 1
Asynchronous transitions:
const fetchMachine = createMachine({
initial: 'idle',
states: {
idle: {
on: {
FETCH: {
target: 'loading',
actions: async () => {
const response = await fetch('https://api.example.com/data');
const data = await response.json();
return { data };
},
},
},
},
loading: {
on: {
RESOLVE: 'success',
REJECT: 'error',
},
},
success: {},
error: {},
},
});
await fetchMachine.transition('FETCH');
console.log(fetchMachine.state); // 'success' or 'error' depending on the fetch result
Getting Started
To use Harper in your project, first install it via npm:
npm install harper
Then, import and use it in your JavaScript code:
import { createMachine } from 'harper';
const myMachine = createMachine({
initial: 'state1',
states: {
state1: { on: { NEXT: 'state2' } },
state2: { on: { NEXT: 'state1' } },
},
});
console.log(myMachine.state); // 'state1'
myMachine.transition('NEXT');
console.log(myMachine.state); // 'state2'
Competitor Comparisons
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Pros of Playwright
- Supports multiple browsers (Chromium, Firefox, WebKit) out of the box
- Offers a rich API for advanced automation scenarios
- Has strong community support and regular updates
Cons of Playwright
- Steeper learning curve due to more complex API
- Requires more setup and configuration for basic tasks
- Larger package size and dependencies
Code Comparison
Harper:
const harper = require('harper');
harper.visit('https://example.com')
.click('#button')
.screenshot('example.png')
.done();
Playwright:
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.click('#button');
await page.screenshot({ path: 'example.png' });
await browser.close();
})();
Summary
Playwright offers more advanced features and multi-browser support, making it suitable for complex automation tasks. However, it comes with a steeper learning curve and more setup requirements. Harper, on the other hand, provides a simpler API for basic web automation tasks, making it easier to get started but potentially limiting for more advanced scenarios.
Fast, easy and reliable testing for anything that runs in a browser.
Pros of Cypress
- More comprehensive end-to-end testing framework with built-in assertion library
- Larger community and ecosystem, with extensive documentation and plugins
- Real-time reloading and debugging capabilities
Cons of Cypress
- Limited cross-browser support compared to Harper
- Steeper learning curve for beginners
- Potential performance issues with large test suites
Code Comparison
Harper:
const { test } = require('@playwright/test');
test('example test', async ({ page }) => {
await page.goto('https://example.com');
await page.click('button');
await page.waitForSelector('.result');
});
Cypress:
describe('Example Test', () => {
it('performs an action', () => {
cy.visit('https://example.com');
cy.get('button').click();
cy.get('.result').should('be.visible');
});
});
Harper is a lightweight, Playwright-based testing tool focused on simplicity and ease of use. It's designed for quick setup and straightforward test creation, making it ideal for smaller projects or teams new to automated testing.
Cypress, on the other hand, offers a more robust testing environment with advanced features like time-travel debugging and automatic waiting. It's well-suited for complex applications and teams with more testing experience.
While Harper's syntax is more concise and closer to standard JavaScript, Cypress uses a custom command structure that can be more intuitive for certain testing scenarios. Both tools have their strengths, and the choice between them depends on project requirements and team preferences.
JavaScript API for Chrome and Firefox
Pros of Puppeteer
- More comprehensive and feature-rich for web automation and scraping
- Larger community and ecosystem, with extensive documentation and examples
- Supports both Chrome and Firefox browsers
Cons of Puppeteer
- Heavier and more resource-intensive
- Steeper learning curve for beginners
- May be overkill for simple screenshot tasks
Code Comparison
Harper (simplified screenshot capture):
const harper = require('harper');
const browser = await harper.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'screenshot.png' });
Puppeteer (equivalent functionality):
const puppeteer = require('puppeteer');
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'screenshot.png' });
Summary
Harper is a lightweight, focused tool for capturing screenshots, while Puppeteer is a more comprehensive browser automation library. Harper is simpler to use for basic screenshot tasks, but Puppeteer offers greater flexibility and features for complex web automation scenarios. The code comparison shows that both libraries have similar syntax for basic operations, but Puppeteer's additional capabilities come with increased complexity and resource requirements.
A browser automation framework and ecosystem.
Pros of Selenium
- Widely adopted and mature web automation framework with extensive community support
- Supports multiple programming languages (Java, Python, C#, etc.)
- Comprehensive documentation and extensive ecosystem of tools and plugins
Cons of Selenium
- Can be slower and more resource-intensive compared to lightweight alternatives
- Setup and configuration can be complex, especially for beginners
- May require frequent updates to keep up with browser changes
Code Comparison
Selenium (Python):
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://example.com")
element = driver.find_element(By.ID, "my-element")
element.click()
Harper (JavaScript):
const harper = require('harper');
harper.visit('https://example.com');
harper.click('#my-element');
Harper is a lightweight, JavaScript-based web automation tool designed for simplicity and ease of use. It offers a more streamlined API compared to Selenium, making it easier for developers to write and maintain test scripts. However, Harper may lack some of the advanced features and cross-language support that Selenium provides.
While Selenium is a more comprehensive solution for complex web automation tasks across multiple platforms and languages, Harper focuses on providing a simpler, more developer-friendly experience for JavaScript-based projects.
Next-gen browser and mobile automation test framework for Node.js
Pros of WebdriverIO
- More comprehensive and feature-rich automation framework
- Supports multiple programming languages and testing frameworks
- Larger community and ecosystem with extensive documentation
Cons of WebdriverIO
- Steeper learning curve due to its extensive feature set
- May be overkill for simpler testing needs
- Requires more setup and configuration
Code Comparison
Harper:
const { test } = require('@playwright/test');
test('basic test', async ({ page }) => {
await page.goto('https://example.com');
await page.click('button');
await expect(page.locator('.success')).toBeVisible();
});
WebdriverIO:
describe('My Login application', () => {
it('should login with valid credentials', async () => {
await browser.url('https://example.com');
await $('#username').setValue('user');
await $('#password').setValue('password');
await $('button[type="submit"]').click();
await expect($('.success')).toBeExisting();
});
});
Harper is a lightweight, Playwright-based testing framework focused on simplicity and ease of use. It's ideal for quick setup and straightforward testing scenarios. WebdriverIO, on the other hand, offers a more robust and versatile automation solution with support for various browsers, devices, and testing frameworks. While WebdriverIO provides more advanced features and flexibility, it may require more initial setup and learning time compared to Harper's streamlined approach.
Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
Pros of Appium
- Broader platform support (iOS, Android, Windows, macOS)
- Larger community and more extensive documentation
- Supports multiple programming languages for test scripts
Cons of Appium
- More complex setup and configuration
- Slower test execution compared to native frameworks
- Requires more resources and can be less stable
Code Comparison
Harper (JavaScript):
const { createBrowser } = require('@automattic/harper');
const browser = await createBrowser();
await browser.visit('https://example.com');
const title = await browser.evaluate(() => document.title);
await browser.close();
Appium (JavaScript):
const driver = await wdio.remote(capabilities);
await driver.url('https://example.com');
const title = await driver.getTitle();
await driver.deleteSession();
Harper is a lightweight, JavaScript-focused browser automation tool, while Appium is a comprehensive, multi-platform mobile and desktop app testing framework. Harper offers simpler setup and faster execution for web-based tasks, but Appium provides broader device support and cross-platform capabilities. Choose Harper for quick web automation projects, and Appium for extensive mobile and desktop app testing across multiple platforms and programming languages.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Harper
Harper is an English grammar checker designed to be just right. I created it after years of dealing with the shortcomings of the competition.
Grammarly was too expensive and too overbearing. Its suggestions lacked context, and were often just plain wrong. Not to mention: it's a privacy nightmare. Everything you write with Grammarly is sent to their servers. Their privacy policy claims they don't sell the data, but that doesn't mean they don't use it to train large language models and god knows what else. Not only that, but the round-trip-time of the network request makes revising your work all the more tedious.
LanguageTool is great, if you have gigabytes of RAM to spare and are willing to download the ~16GB n-gram dataset. Besides the memory requirements, I found LanguageTool too slow: it would take several seconds to lint even a moderate-size document.
That's why I created Harper: it is the grammar checker that fits my needs. Not only does it take milliseconds to lint a document, take less than 1/50th of LanguageTool's memory footprint, but it is also completely private.
Harper is even small enough to load via WebAssembly.
Language Support
Harper currently only supports English, but the core is extensible to support other languages, so we welcome contributions that allow for other language support.
Performance Issues
We consider long lint times bugs. If you encounter any significant performance issues, please create an issue on the topic.
If you find a fix to any performance issue, we would appreciate the contribution. Just please make sure to read our contribution guidelines first.
Links
- Frequently Asked Questions
- Obsidian Documentation
harper-ls
Documentation- Supported Editors' Documentation
harper.js
Documentation- Official Discord Server
Huge Thanks
This project would not be possible without the hard work from those who contribute.
Harper's logo was designed by Lukas Werner.
Top Related Projects
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Fast, easy and reliable testing for anything that runs in a browser.
JavaScript API for Chrome and Firefox
A browser automation framework and ecosystem.
Next-gen browser and mobile automation test framework for Node.js
Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot