0

I'm using cucumber and sublime text 3 to create some test cases but when I tried to create a snippet for them, the behavior was not as expected, when I call the snippet with tab button nothing happen. I had to figure out what happens and I found that the problem in the code is the $ in the step description.

My snippet:

<snippet>
  <content><![CDATA[
  'use strict';

  module.exports = function() {

    var Given = this.Given,
        When = this.When,
        Then = this.Then;

    Given(/^description$/, function(cb) {
        cb();
    });

    When(/^description$/, function(cb) {
        cb();
    });

    Then(/^description$/, function(cb) {
        cb();
    });
  };
  ]]></content>
    <tabTrigger>step</tabTrigger>
    <scope>source.js</scope>
    <description>To create a step in cucumber</description>
</snippet>

Then when I remove the $ in the description of step the snippet working very fine, but I need this symbol in the step. what I do in this case?

  • Possible duplicate of [Latex Sublime snippet](https://stackoverflow.com/questions/40481224/latex-sublime-snippet) – Keith Hall Jun 14 '17 at 18:05

1 Answers1

0

$ symbol in step description means end of the story line. You need to escape it if you want to use it with escape symbol. For example,

Given("^Unit price is 50\$ currently$")

If we use ^ at beginning and $ at the end then cucumber will do exact match for story and definitions.

Murthi
  • 5,299
  • 1
  • 10
  • 15