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

eslint-plugin-testcafe-community

v2.0.0

Published

Eslint rules for testcafe, from the testcafe community

Downloads

28,929

Readme

eslint-plugin-testcafe-community


What does it do?

This project provides the global variables fixture & test for your ESLint configuration which are specific variables for TestCafe. The recommended configuration enables common rules for best practices when writing tests for TestCafe. The rule descriptions are provided in the table below.

If you use other test suites (Jest/Mocha), make sure to read the compatibility notes at the bottom.

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-testcafe-community:

npm install eslint-plugin-testcafe-community --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-testcafe-community globally.

Recommended configuration

This plugin export a recommended configuration that enforce good practices.

To enable this configuration use the extends property in your .eslintrc config file:

{
    "plugins": ["testcafe-community"],
    "extends": "plugin:testcafe-community/recommended"
}

You may review our example TS/JS package embedded in this repository for an example configuration and plugin testing.

See ESLint documentation for more information about extending configuration files.

Supported Rules

✔️ indicates that a rule is recommended for all users.

🛠 indicates that a rule is fixable.

| Name | ✔️ | 🛠 | Description | | ------------------------------------------------------------------------------------------------------------------------------------- | --- | --- | ----------------------------------------------------------------------- | | expectExpect | ✔️ | | Ensure tests have at least one expect | | noDebug | ✔️ | | Don't allow t.debug() to be committed to the repository. | | noIdenticalTitle | ✔️ | | Don't use identical titles for your tests | | noOnly | ✔️ | | Don't allow test.only to be added to the repository | | noSkip | ✔️ | | Don't allow test.skip or fixture.skip to be added to the repository |

Compatibility

eslint-plugin-testcafe

This eslint-plugin-testcafe-community plugin was a fork from the original eslint-plugin-testcafe project, which has not seen an update since December 2016 (v0.2.1). You do not need to install both packages. This package is an expanded replacement for the original.

eslint-plugin-jest & eslint-plugin-mocha

Due to the similarities between Test-Driven Development (TDD) terminology supported by both Jest & Mocha and the matching terminology for TestCafe's API, you may run into lint confusion errors. This likely happens when your repository includes both Jest/Mocha for unit tests and TestCafe for End-to-End (E2E) tests.

You have a couple solutions to avoid these issues:

  1. [RECOMMENDED] Top-level directory overrides. ESLint configurations work best with a bare minimum base configuration and then specific overrides entries per additional plugin configuration you need to add.

    This is the recommendation since it best conforms to the conventions of these frameworks. Jest recommends unit testing code is always nearest to the code it is testing in multiple __tests__ directories following the file tree your src or lib directories. Since E2E tests are written from a higher level abstraction without regard for how the code actually works, it is best to keep these files at a project root level tests folder. In relation to your eslintrc definition, it is easiest to maintain by defining all the overrides at the top level so that it is easier to debug issues. If you want to share the *.test.{ts,js} filename convention, then you should consider the excludedFiles directive for specific directories (similar to #3).

    A such configuration would look something like this:

    // <project_root>/.eslintrc.js
    
    module.exports = {
        root: true,
        ignorePatterns: ["*.json"],
        // These would affect all files. Note that overrides are combined not replaced
        // extends:[]
        // plugins:[]
        overrides: [
            {
                // For Typescript
                files: ["*.ts"],
                parser: "@typescript-eslint/parser",
                parserOptions: {
                    project: "tsconfig.eslint.json", // Custom lint-only config
                    sourceType: "module"
                },
                plugins: ["@typescript-eslint"],
                extends: [
                    "eslint:recommended",
                    "plugin:@typescript-eslint/recommended",
                    "plugin:@typescript-eslint/recommended-requiring-type-checking",
                    "plugin:prettier/recommended"
                ]
            },
            {
                // TS/JS unit tests (inherits any matches from above)
                // Make sure this entry is specific enough (through regex or excludedFiles)
                // not to match the same files as the e2e files
                files: ["*.spec.{js,ts}", "**/__tests__/**.{js,ts}"],
                env: {
                    "jest/globals": true
                },
                extends: ["plugin:jest/recommended", "plugin:jest/style"],
                plugins: ["jest"]
            },
            {
                // Typescript/JavaScript e2e tests (inherits from any matches above)
                files: ["tests/**.test.{js,ts}"],
                excludedFiles: ["src/**", "lib/**"],
                extends: ["plugin:testcafe-community/recommended"],
                plugins: ["testcafe-community"]
            }
        ]
    };
  2. Filename filters. Use a file naming convention to distinguish the difference between a unit test and an E2E test. Configure ESLint via overrides entry to only apply the jest/mocha plugins to *.spec.ts and testcafe-community plugin rules to *.test.js files.

  3. Single directory configuration. Creates a separate folder to house all your TestCafe specific tests usually at the root level of the project. In this directory, create another .eslintrc configuration file that defines an override entry for the files in this directory and loads the testcafe-community plugin/extension.