diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index ffd160e..d30f86e 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -68,7 +68,7 @@ jobs: mv ./gauge-ts-*.tgz ./gauge-ts/artifacts - name: Upload artifacts for local - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: gauge-ts path: ./gauge-ts/artifacts @@ -93,7 +93,7 @@ jobs: npm ci npm run build - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v4 with: name: gauge-ts path: ./artifacts diff --git a/e2e/specs/parameters.spec b/e2e/specs/parameters.spec index 64bf018..f20f0f2 100644 --- a/e2e/specs/parameters.spec +++ b/e2e/specs/parameters.spec @@ -6,4 +6,5 @@ ## Custom Parameters in steps -* This step uses a custom parameter of type Person and value "{\"name\":\"John\",\"age\":30}" +* Convert custom parameter of type Person and value "{\"name\":\"John\",\"age\":30}" +* Check strings with numbers for example "3 % 4" is correct diff --git a/e2e/tests/parameter.ts b/e2e/tests/parameter.ts index 6f32925..924d28e 100644 --- a/e2e/tests/parameter.ts +++ b/e2e/tests/parameter.ts @@ -8,10 +8,14 @@ export default class Parameter { assert.strictEqual(original.trim(), expected); } - @Step("This step uses a custom parameter of type Person and value ") + @Step("Convert custom parameter of type Person and value ") public async validatePerson(person: Person) { assert.strictEqual(person.name, "John"); assert.strictEqual(person.age, 30); assert.ok(person.isAdult()); } + @Step("Check strings with numbers for example is correct") + async checkStringConversion(value: string) { + assert.strictEqual(value, "3 % 4"); + } } diff --git a/gauge-ts/package.json b/gauge-ts/package.json index 3da2026..03d05be 100644 --- a/gauge-ts/package.json +++ b/gauge-ts/package.json @@ -1,6 +1,6 @@ { "name": "gauge-ts", - "version": "0.3.4", + "version": "0.3.5", "description": "Typescript runner for Gauge", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/gauge-ts/src/processors/params/PrimitiveParser.ts b/gauge-ts/src/processors/params/PrimitiveParser.ts index 2bd4727..cc19c71 100644 --- a/gauge-ts/src/processors/params/PrimitiveParser.ts +++ b/gauge-ts/src/processors/params/PrimitiveParser.ts @@ -27,8 +27,11 @@ export class PrimitiveParser implements ParameterParser { } private convertToNumber(value: string): number | undefined { - const num = Number.parseFloat(value); - return Number.isNaN(num) ? undefined : num; + if (value.trim() === "") { + return undefined; + } + const num = Number(value); + return Number.isFinite(num) ? num : undefined; } private convertToBoolean(value: string): boolean | undefined { diff --git a/gauge-ts/ts.json b/gauge-ts/ts.json index 7d45387..48c7282 100644 --- a/gauge-ts/ts.json +++ b/gauge-ts/ts.json @@ -16,6 +16,6 @@ "linux": ["./launcher.mjs", "--start"], "windows": ["launcher.bat", "--start"] }, - "version": "0.3.4", + "version": "0.3.5", "gRPCSupport": true } diff --git a/package-lock.json b/package-lock.json index 485f36f..d7e4580 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,7 +29,7 @@ } }, "gauge-ts": { - "version": "0.3.3", + "version": "0.3.5", "license": "MIT", "dependencies": { "@grpc/grpc-js": "^1.10.9",