eslint-plugin-tmaiadev-jest-rules

1.1.2 • Public • Published

ESLint Plugin TMaiaDev Jest Rules

This ESLint Plugin will enforce your Jest tests to follow the "Given When Then" and the "it should" patterns.

Setup

  1. Install the dependency
npm install eslint-plugin-tmaiadev-jest-rules --save-dev
  1. Configure your .eslintrc file by adding the plugin to the plugins array, and the rules you want to the rules object.
{
    // ...
    plugins: [
        // ...
        "eslint-plugin-tmaiadev-jest-rules",
    ],
    rules: {
        // ...
        "tmaiadev-jest-rules/enforce-gwt": "error",
        "tmaiadev-jest-rules/enforce-gwt-capitalized": "error",
        "tmaiadev-jest-rules/enforce-it-should": "error",
    },
}

Examples

describe('Given that the user has landed on the product page', () => {
    describe('When the user clicks on the buy button', () => {
       test('Then the product should be added to the shopping cart', () => {
            // ...  
       });
       
       describe('And the product has already been added on the shopping card', () => {
         test('Then the number of items of that product should be increased by 1', () => {
            // ... 
         });
       });
    });
});
describe('Given `isDev()`', () => {
    it('should return true', () => {
        expect(isDev()).toBe(true);
    });
});

Package Sidebar

Install

npm i eslint-plugin-tmaiadev-jest-rules

Weekly Downloads

0

Version

1.1.2

License

ISC

Unpacked Size

8.92 kB

Total Files

10

Last publish

Collaborators

  • tmaiadev