getgauge / gauge-ts

Typescript language plugin for Gauge
MIT License
31 stars 13 forks source link

[0.3.4] "100% Invoiced" is omitting everything after `%` #187

Open mholetzko opened 1 month ago

mholetzko commented 1 month ago

Describe the bug

With 0.3.4 we see a bunch of issues on our test-suites. If we parse e.g. 100% Invoiced to a step variable, then the parsed result is 100 instead of the whole string 100% Invoiced.

This snippet shows the "issue" with the parseFloat implementation

const num1 = Number.parseFloat("100% Invoiced");
const num2 = Number("100% Invoiced")

// Expectation
console.log(Number.isNaN(num1)); -> False -> 100 -> Gauge parses as 100
console.log(Number.isNaN(num2)); -> True -> NaN -> Gauge parses as string as expected

We can henceforth not use version 0.3.4. If I find some time, I can imagine writing up a few more detailed requirements, test cases and implement it, but won't be possible in the next days :)

@lbockstaller

zabil commented 1 month ago

I've tried this with the following.

## Custom Parameters in steps
* This step parses a parameter which is not a number like "100% of the value"

And implementation

  @Step("This step parses a parameter which is not a number like <value>")
  public async validateStringParsing(value: string) {
    assert.strictEqual(value, "100% of the value");
  }

And get the right results

# Parameters
  ## Custom Parameters in steps  ✔100% of the value

My versions

$ node --version                                                                                                                           
v22.4.0

$ Gauge version: 1.6.7
Commit Hash: 684d870

Plugins
-------
html-report (4.3.1)
screenshot (0.2.0)
ts (0.3.4)

The test passes and prints out the correct value (if i add a debug). Can you please provide an example step and implementation to replicate this?

zabil commented 1 month ago

Closing for now. Will re-open if info about steps and implementation and versions are provided.

mholetzko commented 1 month ago

Hey @zabil ,

I was on vacation - I'll try to extract an example incl. versions soon. We have reverted the versions so there is no pressure on our side.

Will post here once I get to it - thanks for the quick reply though!