1.0.0 • Published 6 years ago

html-attribute-checker v1.0.0

Weekly downloads
237
License
MIT
Repository
-
Last release
6 years ago

HMTL Attribute Checker

Internal utility too created to check attributes exist on certain element. Useful if you require every element having a unique ID for E2E testing.

Example usage (from within project root): $ html-attribute-checker --config=/Test/attribute.config.js

Options

The HTML attribute checker comes with its own limited set of options to configure. Look at the attribute.config.js see the different options.

Hierarchy of config: 1. Command line flags e.g --config=config.js 2. Looks for attribute.config.js at the root of the project 3. Internal default config

OptionDescriptionValues
logConsole feedback log levels for when a file is being processed, passes and fails. Can be multiple if you want feedback on everything.['runs', 'success', 'error']
failThresholdNumber of allowed missing IDs before the script throws an errornumber
srcDirSource directory/file to run the script on (accepts globs)stringstring[]
filesIgnorePatternFiles / folders to ignore (accepts globs)stringstring[]
requiredAttributesAttribute to check'id'
checkableElementsHTML elements to check for missing attribute

Example config

module.exports = {
    log: ['error'],
    failThreshold: 20,
    srcDir: 'src/app',
    filesIgnorePattern: [
        'src/app/shared',
    ],
    requiredAttributes: 'id',
    checkableElements: {
        'div': true,
    },
};

Using the tool

Default

By default the tool will use the configuration to determine what files to check and how to check them.

$ html-attribute-checker

Custom config

It is possible to provide a config file to use via the command line. This will run the tool the same as the default above.

$ html-attribute-checker --config=myconfig.js

Custom threshold

You can change the fail threshold from the command line if you wish that run to be different to what is configured in the config file.

$ html-attribute-checker --threshold=3

Custom files and/or folders

It's possible to tell the tool which files or folders you want to run on without having to edit the config file. All you need to do is pass the file/folder which you want to test as an argument.

Folder (This will test all HTML inside the folder included nested directories)

$ html-attribute-checker src/app/example

Single file

$ html-attribute-checker src/app/example/feature.html

Multiple files

$ html-attribute-checker src/app/example/feature.html src/app/example/request.html

Mixed files and folders

$ html-attribute-checker src/app/example src/app/test/test.html