New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

textlint-tester

Package Overview
Dependencies
Maintainers
1
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

textlint-tester

testing tool for textlint rule.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
decreased by-14.52%
Maintainers
1
Weekly downloads
 
Created
Source

textlint-tester Build Status

Mocha test helper library for textlint rule.

Installation

npm install -D textlint-tester mocha

Usage

  1. Write tests by using textlint-tester
  2. Run tests by Mocha

TextLintTester

TextLintTester#run(ruleName, rule, {valid=[], invalid=[]})
  • {string} ruleName ruleName is name of thee rule
  • {Function} rule rule is the function of rule
  • {string[]|object[]} valid
    • e.g.) ["text", { text : "text" }]
  • {object[]} invalid
    • e.g.) [{text: "text", output:"text", errors: [ messages : "expected message" ]}

Example

test/example-test.js:

var TextLintTester = require("textlint-tester");
var tester = new TextLintTester();
// rule
var rule = require("textlint-rule-no-todo");
// ruleName, rule, { valid, invalid }
tester.run("no-todo", rule, {
    valid: [
        "this is test",
        {
            // text with options
            text: "this is test",
            options: {
                "key": "value"
            }
        }
    ],
    invalid: [
        {
            text: "- [ ] string",
            errors: [
                {
                    message: "found TODO: '- [ ] string'"
                }
            ]
        },
        {
            text: "TODO: string",
            options: {"key": "value"},
            errors: [
                {
                    message: "found TODO: 'TODO: string'",
                    line: 1,
                    column: 1
                }
            ]
        },
        {
         text: "TODO: string",
         output: "string" // <= fixed output 
         errors: [
             {
                 message: "found TODO: 'TODO: string'",
                 line: 1,
                 column: 1
             }
         ]
        }
    ]
});

Run the tests:

$(npm bin)/mocha test/

Tests

$(npm bin)/mocha test/
# npm test

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

Keywords

FAQs

Package last updated on 18 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc