npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cypress-spellcheck

v1.0.2

Published

A lightweight cypress module for identifying possible spelling errors found within your application.

Downloads

6

Readme

Forks Stargazers Issues MIT License

About The Project

product-screenshot

This module is designed to help flag spelling mistakes found within your application. While this type of assertion is not necessary for most tests it proves to be beneficial in initial test scripts executed against new products and projects. Once you've had time to write assertions for the static strings in your application you can remove calls to this module from your tests.

Note: The spelling logic found within this module was provided by the spellcheck-js node module.

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

This module is distributed via npm which is bundled with node and should be installed as one of your existing Cypress project's devDependencies.

Installation

Execute the following npm command from your projects root directory.

  npm i cypress-spellcheck --save-dev

Setup

The Cypress Spellcheck Library extends the Cypress' cy command.


  1. To access the spellcheck assertion You must first add this line to your project's cypress/support/commands.js file.
  import "cypress-spellcheck";

Example of a working cypress/support/commands.js file.

import "./commands"
import "../../node_modules/cypress-spellcheck";

  1. Next, you'll need to include the spellCheck task in your cypress.config.js file by adding this to the top of the file.
    const spellCheck = require("cypress-spellcheck/task");

  1. Finally, you'll need to initialize the spellCheck task by including the following call within "setupNodeEvents".
    spellCheck(on);

Full example of a cypress.config.js file

    const { defineConfig } = require("cypress");
    const spellCheck = require("cypress-spellcheck/task");

    module.exports = defineConfig({
        e2e: {
            setupNodeEvents(on, config) {
                spellCheck(on)
            },
        },
    });

You can now use assetions within the Testing Library simply by calling cy.isSpelledCorrectly.

    cy.isSpelledCorrectly("something and something else", "example string");

Usage

To use the assertions in your tests simply call the isSpelledCorrectly function.

  cy.isSpelledCorrectly(string, description, [..., whiteListedCustomWords]);

The function takes three arguments:

  1. (Required) The string of text you wish to verify.
  2. (Required) A description of the text that will be used in the test output.
  3. (Optional) An array of custom words you wish to whitelist for all future test runs.
    1. eg. ["customWordOne", "customWordTwo"]
    2. Note: Whitelisting words is permanent and could negatively impact future test runs.

Example verifying the page title doesn't contain any spelling mistakes:

    it('The page title should not contain any spelling mistakes', () => {
        cy.visit('cypress/e2e/html/no-spelling-mistakes.html').then(() => {
            cy.get('html').then(function (e) {
                let title = e.find('title').text();
                cy.isSpelledCorrectly(title, 'website title');
            });
        });
    });

Example whitelisting a word and verifying the page title doesn't contain any spelling mistakes:

    it('The page title should not contain any spelling mistakes', () => {
        cy.visit('cypress/e2e/html/no-spelling-mistakes.html').then(() => {
            cy.get('html').then(function (e) {
                let title = e.find('title').text();
                cy.isSpelledCorrectly(title, 'website title', ['catz', 'dogz']);
            });
        });
    });

Example iterating over multiple paragraph elements and verifying they do not contain spelling mistakes:

    cy.get('p').each((paragraph) => {
        let text = paragraph.text();
        cy.isSpelledCorrectly(text, `paragraph ("${text}")`);
    });

failed assertion example

Testing The Module

Navigate to the node module and then execute the following command to run a Cypress test against two dummy html documents. The test script contains 36 tests with a total of 18 passing assertions and 18 failing.

    npm run test

The executed test will result in an even number of passed and failed results as the no-spelling-mistakes.html and has-spelling-mistakes.html documents are tested.

test script results

See the open issues for a full list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Project Link: https://github.com/waltir/cypress-spellcheck

Acknowledgments