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-extended

v0.2.0

Published

ESLint rules for creating testcafe fixtures and tests

Downloads

12,314

Readme

eslint-plugin-testcafe-extended

ESLint plugin with custom rules for TestCafe. code linting. This plugin will trigger on .debug() statements, wherever they are used in a test. This plugin will trigger on .only statements, independent of their placement in the fixture or test command chain.

Getting started

Installation

First of all, you need ESLint. installed. And to install this plugin, run:

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

Configuration

The example provided below is with using .eslintrc.js for eslint configuration, but you can also choose to use json format, or name the file specific for test, eg. .eslintrc.test.js. Please review eslint documentation for all configuration possibilities.

Create a .eslintrc.js file in the root of your project. If you just want to use the rules and not the supplied configuration, add the following into this file;

module.exports = {
  plugins: ['testcafe-extended'],
  rules: {
    'testcafe-extended/no-only-statements': ['error'],
    'testcafe-extended/no-debug-statements': ['error'],
  },
};

Running

Add the following to the scripts section in your package.json.

"lint": "eslint ./test --ext js,ts",

Execute npm run lint

If you have a separate configuration to linting testfiles, you could add the following script

"lint:test": "eslint ./test --config .eslintrc.test.js --ext js,ts",

Execute npm run lint:test

Look at the eslint documentation to review all possible commandline options.

Recommended configuration

This plugin exports a recommended configuration that enforces the rules in this plugin and sets the globals fixture and test to false to prevent the is not defined error.

To enable this configuration use the extends property in your .eslintrc.js config file. With this recommende configuration, you don't have to add the testcafe-extended rules yourself, they are contained in the recommended configuration.

module.exports = {
  plugins: ['testcafe-extended'],
  extends: "plugin:testcafe-extended/recommended"
};

Testing

The no-only-statements rule in this plugin are tested with the following occurrences;

| Command | | -------------------------------------------------------------------------------- | | fixture.only`My Fixture`.page('url').requestHooks(hooks); | | fixture`My Fixture`.only.page('url').requestHooks(hooks); | | fixture('My Fixture').only.page('url').requestHooks(hooks); | | fixture.only.page('url').requestHooks(hooks)('My Fixture'); | | fixture`My Fixture`.page('url').only.requestHooks(hooks); | | fixture`My Fixture`.page('url').requestHooks(hooks).only; | | -------------------------------------------------------------------------------- | | test.only('My Test', async t => {}); | | test.requestHooks(hooks).only('My Test', async t => {}); | | test.requestHooks(hooks).before(async t => {}).only('My Test', async t => {}); |

The no-debug-statements rule is tested by placing the .debug() statement on multiple locations, like in a before method or somewhere in the TestController chain and checking if the rule triggered.

Author

Stefan Schenk

Update history

| Version | Description | | ------- | ------------------------------------------------------------------- | | 0.1.0 | Initial release with no-only-statements and no-debug-statements |