Spearmint
Testing, simplified. || An inclusive, accessibility-first GUI for generating clean, semantic Javascript tests in only a few clicks of a button.
Top Related Projects
Delightful JavaScript Testing.
Fast, easy and reliable testing for anything that runs in a browser.
JavaScript API for Chrome and Firefox
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Next-gen browser and mobile automation test framework for Node.js
A browser automation framework and ecosystem.
Quick Overview
Spearmint is an open-source testing suite designed for React applications. It provides a user-friendly interface for developers to create, manage, and run tests for their React components and applications. Spearmint aims to simplify the testing process and make it more accessible to developers of all skill levels.
Pros
- Intuitive graphical user interface for creating and managing tests
- Supports multiple testing types, including unit, integration, and end-to-end tests
- Generates test code automatically, reducing the learning curve for testing
- Integrates well with popular testing libraries like Jest and React Testing Library
Cons
- Limited to React applications, not suitable for other frameworks or vanilla JavaScript
- May require additional setup and configuration for complex projects
- Documentation could be more comprehensive for advanced use cases
- Relatively new project, which may lead to potential stability issues or lack of community support
Code Examples
- Creating a simple unit test for a React component:
import React from 'react';
import { render, screen } from '@testing-library/react';
import MyComponent from './MyComponent';
test('renders MyComponent correctly', () => {
render(<MyComponent />);
const element = screen.getByText('Hello, World!');
expect(element).toBeInTheDocument();
});
- Writing an integration test for a form submission:
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import LoginForm from './LoginForm';
test('submits form with correct data', async () => {
render(<LoginForm />);
fireEvent.change(screen.getByLabelText('Username'), { target: { value: 'testuser' } });
fireEvent.change(screen.getByLabelText('Password'), { target: { value: 'password123' } });
fireEvent.click(screen.getByText('Submit'));
await screen.findByText('Login successful');
expect(screen.getByText('Login successful')).toBeInTheDocument();
});
- Creating an end-to-end test using Cypress:
describe('User Registration', () => {
it('successfully registers a new user', () => {
cy.visit('/register');
cy.get('#username').type('newuser');
cy.get('#email').type('newuser@example.com');
cy.get('#password').type('securepassword');
cy.get('#confirm-password').type('securepassword');
cy.get('button[type="submit"]').click();
cy.url().should('include', '/dashboard');
cy.contains('Welcome, newuser!').should('be.visible');
});
});
Getting Started
To get started with Spearmint, follow these steps:
-
Install Spearmint globally:
npm install -g spearmint
-
Navigate to your React project directory and run Spearmint:
cd your-react-project spearmint
-
The Spearmint GUI will open in your default browser. Use the interface to create and manage your tests.
-
Run your tests using the Spearmint interface or your preferred test runner.
Competitor Comparisons
Delightful JavaScript Testing.
Pros of Jest
- Widely adopted and well-maintained testing framework with extensive documentation
- Built-in code coverage reporting and snapshot testing capabilities
- Supports parallel test execution for faster performance
Cons of Jest
- Steeper learning curve for beginners compared to Spearmint's user-friendly interface
- Requires more manual configuration and setup for complex testing scenarios
- Less focus on visual test creation and management
Code Comparison
Jest:
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
Spearmint:
it('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).to.equal(3);
});
While the syntax is similar, Spearmint provides a more intuitive interface for creating and managing tests, especially for those new to testing. Jest, on the other hand, offers more advanced features and customization options for experienced developers.
Jest excels in large-scale projects with complex testing requirements, while Spearmint focuses on simplifying the test creation process for React applications. Jest's extensive ecosystem and community support make it a popular choice for many developers, but Spearmint's user-friendly approach can be beneficial for teams looking to streamline their testing workflow.
Fast, easy and reliable testing for anything that runs in a browser.
Pros of Cypress
- More mature and widely adopted, with extensive documentation and community support
- Offers real-time reloading and time-travel debugging for efficient test development
- Provides built-in waiting mechanisms and automatic retries for handling asynchronous operations
Cons of Cypress
- Limited to testing web applications within a browser environment
- Lacks native support for multi-tab testing and cross-domain testing without workarounds
- Can be slower for large test suites due to its browser-based approach
Code Comparison
Cypress:
describe('Login', () => {
it('should log in successfully', () => {
cy.visit('/login')
cy.get('#username').type('user@example.com')
cy.get('#password').type('password123')
cy.get('button[type="submit"]').click()
cy.url().should('include', '/dashboard')
})
})
Spearmint:
describe('Login', () => {
it('should log in successfully', () => {
render(<Login />)
fireEvent.change(screen.getByLabelText('Username'), { target: { value: 'user@example.com' } })
fireEvent.change(screen.getByLabelText('Password'), { target: { value: 'password123' } })
fireEvent.click(screen.getByRole('button', { name: 'Submit' }))
expect(screen.getByText('Welcome to Dashboard')).toBeInTheDocument()
})
})
JavaScript API for Chrome and Firefox
Pros of Puppeteer
- More mature and widely adopted project with extensive documentation
- Supports a broader range of browser automation tasks beyond testing
- Actively maintained by Google, ensuring regular updates and improvements
Cons of Puppeteer
- Steeper learning curve for beginners compared to Spearmint's user-friendly interface
- Requires more setup and configuration for basic testing scenarios
- Less focused on React component testing specifically
Code Comparison
Puppeteer example:
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({path: 'screenshot.png'});
await browser.close();
Spearmint example:
describe('MyComponent', () => {
it('renders correctly', () => {
const wrapper = shallow(<MyComponent />);
expect(wrapper).toMatchSnapshot();
});
});
While Puppeteer excels in browser automation and general web scraping tasks, Spearmint is more tailored for React component testing with a user-friendly interface. Puppeteer offers greater flexibility but requires more setup, whereas Spearmint provides a streamlined experience for React developers focusing on component testing.
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Pros of Playwright
- Broader browser support (Chromium, Firefox, WebKit)
- More comprehensive API for advanced automation scenarios
- Stronger community support and regular updates
Cons of Playwright
- Steeper learning curve for beginners
- Requires more setup and configuration
Code Comparison
Playwright:
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await browser.close();
})();
Spearmint:
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import App from '../App';
it('renders without crashing', () => {
render(<App />);
});
Playwright offers a more low-level approach to browser automation, while Spearmint focuses on React component testing with a user-friendly interface. Playwright provides greater flexibility for complex scenarios across multiple browsers, but Spearmint offers a simpler setup for React-specific testing. The choice between the two depends on the project's specific needs and the development team's expertise.
Next-gen browser and mobile automation test framework for Node.js
Pros of WebdriverIO
- More mature and widely adopted project with a larger community
- Supports multiple programming languages and testing frameworks
- Extensive documentation and robust ecosystem of plugins
Cons of WebdriverIO
- Steeper learning curve for beginners
- More complex setup and configuration process
- Potentially overwhelming feature set for simple testing needs
Code Comparison
WebdriverIO:
describe('My Login application', () => {
it('should login with valid credentials', async () => {
await browser.url(`https://the-internet.herokuapp.com/login`);
await $('#username').setValue('tomsmith');
await $('#password').setValue('SuperSecretPassword!');
await $('button[type="submit"]').click();
await expect($('#flash')).toBeExisting();
});
});
Spearmint:
describe('Login Test', () => {
it('should login successfully', () => {
cy.visit('https://example.com/login');
cy.get('#username').type('user@example.com');
cy.get('#password').type('password123');
cy.get('button[type="submit"]').click();
cy.url().should('include', '/dashboard');
});
});
Both examples demonstrate a simple login test, but WebdriverIO uses async/await syntax and browser-specific selectors, while Spearmint utilizes Cypress commands and chainable assertions.
A browser automation framework and ecosystem.
Pros of Selenium
- Widely adopted and supported across multiple programming languages
- Extensive documentation and large community for troubleshooting
- Robust set of features for web automation and testing
Cons of Selenium
- Steeper learning curve, especially for beginners
- Can be slower in execution compared to more lightweight alternatives
- Requires more setup and configuration for different browsers
Code Comparison
Selenium (Python):
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://www.example.com")
element = driver.find_element(By.ID, "example-id")
element.click()
driver.quit()
Spearmint (JavaScript):
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://www.example.com');
await page.click('#example-id');
await browser.close();
})();
While Selenium is a more established and versatile tool for web automation across multiple languages, Spearmint (which uses Playwright under the hood) offers a more modern and user-friendly approach, particularly for JavaScript developers. Selenium's extensive features and cross-language support come at the cost of complexity, while Spearmint provides a simpler, more streamlined experience for web testing and automation tasks.
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
ð ⨠Spearmint v14 ⨠ð
Spearmint helps developers easily create functional Accessibility, Endpoint, GraphQL, Puppeteer, React, Hooks, Redux, Svelte, Vue, Security, and Solid.js tests without writing any code. It dynamically converts user inputs into executable Jest test code by using DOM query selectors provided by @testing-library.
Installation
Please download Spearmint from our website
How to use in development mode
Please refer to README-dev.md
How it works
-
Open the folder of the repo you'd like to create tests for, then choose the framework/type of test you'd like to create.
-
Utilize our auto-complete, drop-down options, and tooltips features to easily create arrangement, action, and assertion test statements for React, Vue, Svelte, and Solid; reducer, action creator, asynchronous action creator, and middleware test statements for Redux; and hooks, context, endpoint, and GraphQL test statements.
-
Spearmint will then convert user input to dynamically generate a test file in the Code Editor.
-
Follow the instructions in the recently added User Guide tab on the right to export and run your tests.
-
Don't forget to select your test file from the left panel in order to manually edit the test in the Test Editor; otherwise the changes won't be reflected in the test file.
For developers: README-dev.md. This containes more information specific to developers such as data systems, outlines of the application, turning on dev tools, etc.
New features with version 0.14.0
-
Increased Typescript coverage â Spearmint is now majority Typescript!
-
Greatly bolstered internal testing on the program and instituted testing coverage reports for completeness visibility
-
Updated to latest version of electron
-
Updated a variety of dependencies and libraries
-
Added documentation for future developers
Iteration Roadmap
- Continuing TypeScript Conversion:
- This will help with the maintainability and readability of Spearmintâs code, and move closer to 100% coverage
- Persistent data:
- There is a framework for login, including GitHub and Google, however it is not implemented
- Adding more features to make login and user data more valuable, such as favorited or saved tests, saved templates, etc.
- Adding more testing:
- Deeper testing of existing frameworks should probably be the main priority here as many frameworks are implemented already, but could use more fleshed-out features
- Adding additional frameworks is a possibility if there is a strong case for them, but adding more robustness to the current test suites is probably more important
- Add functionality for exporting test files as Typescript
- Currently the only export option is vanilla Javascript
- Continue to extend internal testing coverage
- A far greater amount of the application is tested now than it was previously, but there is more work to do on this
- Update some dependencies and tools
- Consider removing MUI and switching to another component library or redoing styling in CSS in order to update the program to React v18+ as MUI is incompatible and seems not to be actively updating.
- Consider implementing React Dev Tools or react-dnd to restore the drag-drop functionality
- Monitor for other opportunities to update dependencies or otherwise improve the program with different libraries or tools.
- Revamp UI for certain test cases:
- Some of test cases needs improvement on UI as they do not have any styling or optimal user experience
Known Bugs
- Screen reader for Accessibilty can turn on and off but does not read.
- Text to speech not functioning properly under Accessibility
- Some elements of draggable remaining in Redux test case components
The Spearmint Team
Top Related Projects
Delightful JavaScript Testing.
Fast, easy and reliable testing for anything that runs in a browser.
JavaScript API for Chrome and Firefox
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Next-gen browser and mobile automation test framework for Node.js
A browser automation framework and ecosystem.
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