How to use the gherkin-ast.Tag function in gherkin-ast

To help you get started, we’ve selected a few gherkin-ast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gherking / gherking / test / builtIn / RemoveDuplicates.spec.js View on Github external
it('should remove tag if presents on parent', () => {
            const compiler = new RemoveDuplicates();
            const element = {tags: [new Tag('@onFeature')]};
            const parent = {tags: [new Tag('@onFeature')]};

            compiler._filterTags(element, parent);
            expect(element.tags).to.have.length(0);
            expect(parent.tags).to.have.length(1);
        });
github gherking / gherking / test / builtIn / Macro.spec.js View on Github external
it('should process macro steps', () => {
        const scenario_macro = new Scenario();
        const tag = new Tag('@macro(test)');
        const step_macro = new Step('When', 'test step');
        const step_test = new Step('And', 'macro test is executed');

        scenario_macro.tags.push(tag);
        scenario_macro.steps.push(step_macro);

        macro.preFilterScenario(scenario_macro);
        expect(macro.onStep(step_test)).to.eql(scenario_macro.steps);
    });
github gherking / gherking / test / builtIn / ForLoop.spec.js View on Github external
it('should return the correct iterator', () => {
            const loop = new ForLoop();
            const scenario = new Scenario('Scenario', 'Scenario name');
            const tag = new Tag('@loop(4)');
            scenario.tags.push(tag);

            expect(loop.getIterationNumber(scenario)).to.eql(4);
        });
    });
github gherking / gherking / test / builtIn / ForLoop.spec.js View on Github external
it('should throw an error when provided iterator exceeds maximum', () => {
            const loop = new ForLoop();
            const scenario = new Scenario('Scenario', 'Scenario name');
            const tag = new Tag('@loop(42)');
            scenario.tags.push(tag);

            expect(() => loop.getIterationNumber(scenario)).to.throw(Error);
        });
github gherking / gherking / test / builtIn / Macro.spec.js View on Github external
it('should not filter out non macro scenarios', () => {
        const scenario = new Scenario();
        const tag = new Tag('@notmacro');

        scenario.tags.push(tag);
        expect(macro.preFilterScenario(scenario)).to.be.undefined;
    });
github gherking / gherking / test / builtIn / RemoveDuplicates.spec.js View on Github external
it('should not remove unique tags', () => {
            const compiler = new RemoveDuplicates();
            const element = {tags: [new Tag('@duplicate'), new Tag('@notDuplicate')]};
            const parent = {tags: []};

            compiler._filterTags(element, parent);
            expect(element.tags).to.have.length(2);
            expect(element.tags[0].name).to.equal('@duplicate');
            expect(element.tags[1].name).to.equal('@notDuplicate');
        });
github gherking / gherking / test / builtIn / RemoveDuplicates.spec.js View on Github external
it('should not remove unique tag if not present on parent', () => {
            const compiler = new RemoveDuplicates();
            const element = {tags: [new Tag('@onScenario')]};
            const parent = {tags: [new Tag('@onFeature')]};

            compiler._filterTags(element, parent);
            expect(element.tags).to.have.length(1);
            expect(element.tags[0].name).to.equal('@onScenario');
        });
github gherking / gherking / test / builtIn / Macro.spec.js View on Github external
it('should throw an error when a macro name is already defined', () => {
        const scenario = new Scenario();
        const scenario_2 = new Scenario();
        const tag = new Tag('@macro(testname)');
        const step = new Step('Given', 'step');

        scenario.tags.push(tag);
        scenario_2.tags.push(tag);
        scenario.steps.push(step);

        macro.macros.testname = scenario;

        expect(() => macro.preFilterScenario(scenario_2)).to.throw(Error);
    });
github gherking / gherking / test / builtIn / RemoveDuplicates.spec.js View on Github external
it('should identify if a tag present on parent', () => {
            const compiler = new RemoveDuplicates();
            expect(compiler._hasTag({}, '@noTag'), 'identify if no tags field').to.be.false;
            expect(compiler._hasTag({tags: []}, '@noTag'), 'identify if no tags at all').to.be.false;
            expect(compiler._hasTag({tags: [new Tag('@found')]}, '@found'), 'identify if tag found').to.be.true;
            expect(compiler._hasTag({tags: [new Tag('@notFound')]}, '@noTag'), 'identify if tag not found').to.be.false;
        });
github gherking / gherking / test / builtIn / Macro.spec.js View on Github external
it('should process macro scenarios', () => {
        const scenario = new Scenario();
        const tag = new Tag('@macro(test_tag)');
        const step = new Step('Given', 'random step');

        scenario.tags.push(tag);
        scenario.steps.push(step);

        macro.preFilterScenario(scenario);

        expect(macro.macros.test_tag.steps).to.be.eql(scenario.steps);
    });

gherkin-ast

JS model for Gherkin feature files

MIT
Latest version published 4 months ago

Package Health Score

73 / 100
Full package analysis