Table parameters should obey the expected type
x80486 opened this issue · 2 comments
Describe the bug
Table parameters are passed as strings into steps. If I have a specification with a table that contains floating-point numbers, and the corresponding steps are expecting a type number
it shouldn't be passed as anything than number
s.
I'm not entirely sure if this is a problem with this library, but since I'm using TypeScript with Gauge I would expect the issue from this library.
To Reproduce
-
Set up a project with TypeScript support
-
Create a specification like this one:
# Bank Account Operation(s) Bank Account Operation(s) specification heading description |Balance|Amount|Total| |-------|------|-----| |0.00 |23.50 |23.50| |10.01 |41.83 |51.84| |0.10 |0.00 |0.10 | ## Deposit Money Deposit Money scenario description * Given a bank account with starting balance of <Balance> * When an amount equaling <Amount> is deposited * Then the resulting bank account balance should be <Total>
-
Corresponding step class for aforementioned specification:
import { Step } from "gauge-ts"; export default class BankAccountSteps { // https://bugdiver.dev/gauge-ts/ @Step("Given a bank account with starting balance of <Balance>") public given(balance: number): void { console.log("==> typeof balance:", typeof balance === "number"); // false } // ... }
Expected behavior
Typed values should obey their assigned types accordingly.
Desktop (please complete the following information):
- OS:
Linux uplink 5.4.64-1-lts #1 SMP Wed, 09 Sep 2020 18:54:16 +0000 x86_64 GNU/Linux
- Gauge and plugin version [run
gauge -v
]:Gauge version: 1.1.1 Commit Hash: 6e0d83f Plugins ------- html-report (4.0.12) screenshot (0.0.1) ts (0.0.5)
- Node version [run
node -v
]: v12.18.2 - Npm version [run
npm -v
]: 6.14.5
@x80486 The Table type parameter support has been added. But I'm afraid that that won't be solving your problem because that feature is for the Table parameters passed to steps.
Here the table is a data table managed by Gauge, it passes the values as string only.
We need to convert the parameter to a specific object before calling the implementation function.
I'll try to add a fix soon for it