diff --git a/.eslintignore b/.eslintignore index 55ce0d5..ac11ddf 100644 --- a/.eslintignore +++ b/.eslintignore @@ -10,4 +10,6 @@ package.json package-lock.json .eslintrc.js src/gen -config.ts \ No newline at end of file +config.ts +jest.config.js +launcher.js \ No newline at end of file diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 6bdbdb5..a7f66b2 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,4 +1,4 @@ -name: Node CI +name: test on: [push, pull_request] @@ -51,12 +51,14 @@ jobs: needs: build-artifacts strategy: matrix: - node-version: [12.x, 14.x] + node-version: [12.x, 13.x, 14.x] os: [macOS-latest, ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - uses: BugDiver/setup-gauge@master + with: + gauge-version: master - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 diff --git a/.gitignore b/.gitignore index 13f3785..1ca5d03 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* deploy/ -artifacts/ \ No newline at end of file +artifacts/ +*.tgz \ No newline at end of file diff --git a/.npmignore b/.npmignore index 2c3f823..8b44ea3 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,5 @@ +.github +.vscode test src gauge-proto @@ -16,3 +18,6 @@ azure* *.ps1 *.bat docs +.eslintignore +.eslintrc.js +config.ts diff --git a/build.sh b/build.sh index 534c927..c290b0d 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/zsh +#!/bin/bash function checkCommand() { command -v $1 >/dev/null 2>&1 || { echo >&2 "$1 is not installed, aborting."; exit 1; } diff --git a/config.ts b/config.ts index 34bb34a..5923a88 100644 --- a/config.ts +++ b/config.ts @@ -1 +1,3 @@ -import 'jest-ts-auto-mock'; \ No newline at end of file +import 'jest-ts-auto-mock'; +import { tmpdir } from 'os'; +process.env.gauge_screenshots_dir = tmpdir() \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index f8509b9..3b7477e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -14,6 +14,6 @@ module.exports = { "src/utils/*" ], setupFiles: [ - "config.ts" + "config.ts", ] }; \ No newline at end of file diff --git a/launcher.js b/launcher.js index 4df49cf..65e82bc 100755 --- a/launcher.js +++ b/launcher.js @@ -8,8 +8,8 @@ if (parseInt(version[0]) < 10) { } let stepImpl = ` -import { Step } from "gauge-ts"; -import { equal } from "assert"; +import { Step, Table } from "gauge-ts"; +import { strictEqual } from "assert"; export default class StepImplementation { @@ -22,13 +22,16 @@ export default class StepImplementation { @Step("The word has vowels.") public async verifyVowelsCountInWord(word: string, expectedCount: number) { - equal(await this.countVowels(word), expectedCount); + strictEqual(this.countVowels(word), parseInt(expectedCount)); } @Step("Almost all words have vowels ") - public async verifyVowelsCountInMultipleWords(wordsTable: any) { - for (const row of wordsTable.rows) { - equal(await this.countVowels(row.cells[0]), parseInt(row.cells[1])); + public async verifyVowelsCountInMultipleWords(table: Table) { + for (let row of table.getTableRows()) { + let word: string = row.getCell("Word"); + let expectedCount = parseInt(row.getCell("Vowel Count")); + let actualCount = this.countVowels(word); + strictEqual(expectedCount, actualCount); } } diff --git a/package-lock.json b/package-lock.json index 7a7953e..f2e8002 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "gauge-ts", - "version": "0.0.7", + "version": "0.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -481,9 +481,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -575,9 +575,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -697,9 +697,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -769,9 +769,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -838,9 +838,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -929,9 +929,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -1010,9 +1010,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -1104,9 +1104,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -1422,9 +1422,9 @@ "dev": true }, "@types/yargs": { - "version": "13.0.10", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-13.0.10.tgz", - "integrity": "sha512-MU10TSgzNABgdzKvQVW1nuuT+sgBMWeXNc3XOs5YXV5SDAK+PPja2eUuBNB9iqElu03xyEDqlnGw0jgl4nbqGQ==", + "version": "13.0.11", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-13.0.11.tgz", + "integrity": "sha512-NRqD6T4gktUrDi1o1wLH3EKC1o2caCr7/wR87ODcbVITQF106OM3sFN92ysZ++wqelOd1CTzatnOBRDYYG6wGQ==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -2067,9 +2067,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -3292,9 +3292,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -3762,9 +3762,9 @@ } }, "google-auth-library": { - "version": "6.0.6", - "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-6.0.6.tgz", - "integrity": "sha512-fWYdRdg55HSJoRq9k568jJA1lrhg9i2xgfhVIMJbskUmbDpJGHsbv9l41DGhCDXM21F9Kn4kUwdysgxSYBYJUw==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-6.1.0.tgz", + "integrity": "sha512-GbalszIADE1YPWhUyfFMrkLhFHnlAgoRcqGVW+MsLDPsuaOB5MRPk7NNafPDv9SherNE4EKzcYuxMJjaxzXMOw==", "requires": { "arrify": "^2.0.0", "base64-js": "^1.3.0", @@ -4531,9 +4531,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -4621,9 +4621,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -4740,9 +4740,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -4893,9 +4893,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -4984,9 +4984,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -5056,9 +5056,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -5142,9 +5142,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -5269,9 +5269,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -5349,9 +5349,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -5437,9 +5437,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -5547,9 +5547,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -5658,9 +5658,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -5750,9 +5750,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -5819,9 +5819,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -5905,9 +5905,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -5997,9 +5997,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -6088,9 +6088,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -6208,9 +6208,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -6323,9 +6323,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -6420,9 +6420,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -7064,9 +7064,9 @@ } }, "moment": { - "version": "2.28.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.28.0.tgz", - "integrity": "sha512-Z5KOjYmnHyd/ukynmFd/WwyXHd7L4J9vTI/nn5Ap9AVUgaAE15VvQ9MOGmJJygEUklupqIrFnor/tjTwRU+tQw==", + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.0.tgz", + "integrity": "sha512-z6IJ5HXYiuxvFTI6eiQ9dm77uE0gyy1yXNApVHqTcnIKfY9tIwEjlzsZ6u1LQXvVgKeTnv9Xm7NDvJ7lso3MtA==", "dev": true }, "ms": { @@ -9082,9 +9082,9 @@ } }, "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "version": "15.0.7", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz", + "integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -9164,9 +9164,9 @@ } }, "yargs-parser": { - "version": "20.1.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.1.0.tgz", - "integrity": "sha512-RV4YEjMLfjWkK9jNV/aZytlJ5uz+JBk7t29FofILa41jJAU/yCwghgsjH2xT0h7eu7b6MrCDJb1qZjeDJ/jI1w==", + "version": "20.2.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.0.tgz", + "integrity": "sha512-2agPoRFPoIcFzOIp6656gcvsg2ohtscpw2OINr/q46+Sq41xz2OYLqx5HRHabmFU1OARIPAYH5uteICE7mn/5A==", "dev": true } } diff --git a/package.json b/package.json index dd4edd2..d72d100 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gauge-ts", - "version": "0.2.0", + "version": "0.1.0", "description": "Typescript language runner for gauge", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/RunnerServiceImpl.ts b/src/RunnerServiceImpl.ts index 2712a44..a1e0c39 100644 --- a/src/RunnerServiceImpl.ts +++ b/src/RunnerServiceImpl.ts @@ -282,9 +282,11 @@ export class RunnerServiceImpl implements IRunnerServer { } public kill(_call: SUC, callback: sUD): void { - this._server && this._server.forceShutdown(); callback(null, new Empty()); - process.exit(0); + setTimeout(() => { + this._server && this._server.forceShutdown(); + process.exit(0); + }, 100); } private createRpcError(error: Error): RpcError { diff --git a/src/gen/services_grpc_pb.d.ts b/src/gen/services_grpc_pb.d.ts index 6763eb2..d907691 100644 --- a/src/gen/services_grpc_pb.d.ts +++ b/src/gen/services_grpc_pb.d.ts @@ -35,7 +35,7 @@ interface IRunnerService extends grpc.ServiceDefinition { - path: string; // "/gauge.messages.Runner/ValidateStep" + path: "/gauge.messages.Runner/ValidateStep"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -44,7 +44,7 @@ interface IRunnerService_IValidateStep extends grpc.MethodDefinition; } interface IRunnerService_IInitializeSuiteDataStore extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/InitializeSuiteDataStore" + path: "/gauge.messages.Runner/InitializeSuiteDataStore"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -53,7 +53,7 @@ interface IRunnerService_IInitializeSuiteDataStore extends grpc.MethodDefinition responseDeserialize: grpc.deserialize; } interface IRunnerService_IStartExecution extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/StartExecution" + path: "/gauge.messages.Runner/StartExecution"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -62,7 +62,7 @@ interface IRunnerService_IStartExecution extends grpc.MethodDefinition; } interface IRunnerService_IInitializeSpecDataStore extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/InitializeSpecDataStore" + path: "/gauge.messages.Runner/InitializeSpecDataStore"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -71,7 +71,7 @@ interface IRunnerService_IInitializeSpecDataStore extends grpc.MethodDefinition< responseDeserialize: grpc.deserialize; } interface IRunnerService_IStartSpecExecution extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/StartSpecExecution" + path: "/gauge.messages.Runner/StartSpecExecution"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -80,7 +80,7 @@ interface IRunnerService_IStartSpecExecution extends grpc.MethodDefinition; } interface IRunnerService_IInitializeScenarioDataStore extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/InitializeScenarioDataStore" + path: "/gauge.messages.Runner/InitializeScenarioDataStore"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -89,7 +89,7 @@ interface IRunnerService_IInitializeScenarioDataStore extends grpc.MethodDefinit responseDeserialize: grpc.deserialize; } interface IRunnerService_IStartScenarioExecution extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/StartScenarioExecution" + path: "/gauge.messages.Runner/StartScenarioExecution"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -98,7 +98,7 @@ interface IRunnerService_IStartScenarioExecution extends grpc.MethodDefinition; } interface IRunnerService_IStartStepExecution extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/StartStepExecution" + path: "/gauge.messages.Runner/StartStepExecution"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -107,7 +107,7 @@ interface IRunnerService_IStartStepExecution extends grpc.MethodDefinition; } interface IRunnerService_IExecuteStep extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/ExecuteStep" + path: "/gauge.messages.Runner/ExecuteStep"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -116,7 +116,7 @@ interface IRunnerService_IExecuteStep extends grpc.MethodDefinition; } interface IRunnerService_IFinishStepExecution extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/FinishStepExecution" + path: "/gauge.messages.Runner/FinishStepExecution"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -125,7 +125,7 @@ interface IRunnerService_IFinishStepExecution extends grpc.MethodDefinition; } interface IRunnerService_IFinishScenarioExecution extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/FinishScenarioExecution" + path: "/gauge.messages.Runner/FinishScenarioExecution"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -134,7 +134,7 @@ interface IRunnerService_IFinishScenarioExecution extends grpc.MethodDefinition< responseDeserialize: grpc.deserialize; } interface IRunnerService_IFinishSpecExecution extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/FinishSpecExecution" + path: "/gauge.messages.Runner/FinishSpecExecution"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -143,7 +143,7 @@ interface IRunnerService_IFinishSpecExecution extends grpc.MethodDefinition; } interface IRunnerService_IFinishExecution extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/FinishExecution" + path: "/gauge.messages.Runner/FinishExecution"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -152,7 +152,7 @@ interface IRunnerService_IFinishExecution extends grpc.MethodDefinition; } interface IRunnerService_ICacheFile extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/CacheFile" + path: "/gauge.messages.Runner/CacheFile"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -161,7 +161,7 @@ interface IRunnerService_ICacheFile extends grpc.MethodDefinition; } interface IRunnerService_IGetStepName extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/GetStepName" + path: "/gauge.messages.Runner/GetStepName"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -170,7 +170,7 @@ interface IRunnerService_IGetStepName extends grpc.MethodDefinition; } interface IRunnerService_IGetGlobPatterns extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/GetGlobPatterns" + path: "/gauge.messages.Runner/GetGlobPatterns"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -179,7 +179,7 @@ interface IRunnerService_IGetGlobPatterns extends grpc.MethodDefinition; } interface IRunnerService_IGetStepNames extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/GetStepNames" + path: "/gauge.messages.Runner/GetStepNames"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -188,7 +188,7 @@ interface IRunnerService_IGetStepNames extends grpc.MethodDefinition; } interface IRunnerService_IGetStepPositions extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/GetStepPositions" + path: "/gauge.messages.Runner/GetStepPositions"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -197,7 +197,7 @@ interface IRunnerService_IGetStepPositions extends grpc.MethodDefinition; } interface IRunnerService_IGetImplementationFiles extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/GetImplementationFiles" + path: "/gauge.messages.Runner/GetImplementationFiles"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -206,7 +206,7 @@ interface IRunnerService_IGetImplementationFiles extends grpc.MethodDefinition; } interface IRunnerService_IImplementStub extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/ImplementStub" + path: "/gauge.messages.Runner/ImplementStub"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -215,7 +215,7 @@ interface IRunnerService_IImplementStub extends grpc.MethodDefinition; } interface IRunnerService_IRefactor extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/Refactor" + path: "/gauge.messages.Runner/Refactor"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -224,7 +224,7 @@ interface IRunnerService_IRefactor extends grpc.MethodDefinition; } interface IRunnerService_IKill extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Runner/Kill" + path: "/gauge.messages.Runner/Kill"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -413,7 +413,7 @@ interface IReporterService extends grpc.ServiceDefinition { - path: string; // "/gauge.messages.Reporter/NotifyExecutionStarting" + path: "/gauge.messages.Reporter/NotifyExecutionStarting"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -422,7 +422,7 @@ interface IReporterService_INotifyExecutionStarting extends grpc.MethodDefinitio responseDeserialize: grpc.deserialize; } interface IReporterService_INotifySpecExecutionStarting extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Reporter/NotifySpecExecutionStarting" + path: "/gauge.messages.Reporter/NotifySpecExecutionStarting"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -431,7 +431,7 @@ interface IReporterService_INotifySpecExecutionStarting extends grpc.MethodDefin responseDeserialize: grpc.deserialize; } interface IReporterService_INotifyScenarioExecutionStarting extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Reporter/NotifyScenarioExecutionStarting" + path: "/gauge.messages.Reporter/NotifyScenarioExecutionStarting"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -440,7 +440,7 @@ interface IReporterService_INotifyScenarioExecutionStarting extends grpc.MethodD responseDeserialize: grpc.deserialize; } interface IReporterService_INotifyStepExecutionStarting extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Reporter/NotifyStepExecutionStarting" + path: "/gauge.messages.Reporter/NotifyStepExecutionStarting"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -449,7 +449,7 @@ interface IReporterService_INotifyStepExecutionStarting extends grpc.MethodDefin responseDeserialize: grpc.deserialize; } interface IReporterService_INotifyStepExecutionEnding extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Reporter/NotifyStepExecutionEnding" + path: "/gauge.messages.Reporter/NotifyStepExecutionEnding"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -458,7 +458,7 @@ interface IReporterService_INotifyStepExecutionEnding extends grpc.MethodDefinit responseDeserialize: grpc.deserialize; } interface IReporterService_INotifyScenarioExecutionEnding extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Reporter/NotifyScenarioExecutionEnding" + path: "/gauge.messages.Reporter/NotifyScenarioExecutionEnding"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -467,7 +467,7 @@ interface IReporterService_INotifyScenarioExecutionEnding extends grpc.MethodDef responseDeserialize: grpc.deserialize; } interface IReporterService_INotifySpecExecutionEnding extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Reporter/NotifySpecExecutionEnding" + path: "/gauge.messages.Reporter/NotifySpecExecutionEnding"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -476,7 +476,7 @@ interface IReporterService_INotifySpecExecutionEnding extends grpc.MethodDefinit responseDeserialize: grpc.deserialize; } interface IReporterService_INotifyExecutionEnding extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Reporter/NotifyExecutionEnding" + path: "/gauge.messages.Reporter/NotifyExecutionEnding"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -485,7 +485,7 @@ interface IReporterService_INotifyExecutionEnding extends grpc.MethodDefinition< responseDeserialize: grpc.deserialize; } interface IReporterService_INotifySuiteResult extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Reporter/NotifySuiteResult" + path: "/gauge.messages.Reporter/NotifySuiteResult"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -494,7 +494,7 @@ interface IReporterService_INotifySuiteResult extends grpc.MethodDefinition; } interface IReporterService_IKill extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Reporter/Kill" + path: "/gauge.messages.Reporter/Kill"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -591,7 +591,7 @@ interface IDocumenterService extends grpc.ServiceDefinition { - path: string; // "/gauge.messages.Documenter/GenerateDocs" + path: "/gauge.messages.Documenter/GenerateDocs"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; @@ -600,7 +600,7 @@ interface IDocumenterService_IGenerateDocs extends grpc.MethodDefinition; } interface IDocumenterService_IKill extends grpc.MethodDefinition { - path: string; // "/gauge.messages.Documenter/Kill" + path: "/gauge.messages.Documenter/Kill"; requestStream: false; responseStream: false; requestSerialize: grpc.serialize; diff --git a/src/index.ts b/src/index.ts index 6472954..0f8aae6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ -import {ExecutionContext} from './public/context/ExecutionContext'; -import {Scenario} from './public/context/Scenario'; -import {Specification} from './public/context/Specification'; -import {StepInfo} from './public/context/StepInfo'; +import { ExecutionContext } from './public/context/ExecutionContext'; +import { Scenario } from './public/context/Scenario'; +import { Specification } from './public/context/Specification'; +import { StepInfo } from './public/context/StepInfo'; import { AfterScenario, AfterSpec, @@ -16,10 +16,12 @@ import { CustomScreenshotWriter, Step } from './public/decorators'; -import {Gauge} from './public/Gauge'; -import {Operator} from './public/Operator'; -import {DataStore} from './stores/DataStore'; -import {DataStoreFactory} from './stores/DataStoreFactory'; +import { Gauge } from './public/Gauge'; +import { Operator } from './public/Operator'; +import { Table } from './public/Table'; +import { TableRow } from './public/TableRow'; +import { DataStore } from './stores/DataStore'; +import { DataStoreFactory } from './stores/DataStoreFactory'; export { Gauge, @@ -41,5 +43,7 @@ export { ExecutionContext, Specification, Scenario, - StepInfo + StepInfo, + Table, + TableRow }; diff --git a/src/processors/StepExecutionProcessor.ts b/src/processors/StepExecutionProcessor.ts index adec67b..32d01e0 100644 --- a/src/processors/StepExecutionProcessor.ts +++ b/src/processors/StepExecutionProcessor.ts @@ -1,11 +1,12 @@ import { ExecuteStepRequest, ExecutionStatusResponse } from '../gen/messages_pb'; -import { ProtoExecutionResult, ProtoTable } from '../gen/spec_pb'; +import { Parameter, ProtoExecutionResult, ProtoTable } from '../gen/spec_pb'; import registry from '../models/StepRegistry'; import { Screenshot } from "../screenshot/Screenshot"; import { MessageStore } from "../stores/MessageStore"; import { ScreenshotStore } from "../stores/ScreenshotStore"; import { ExecutionProcessor } from "./ExecutionProcessor"; import { CommonFunction } from '../utils/Util'; +import { Table } from '../public/Table'; export class StepExecutionProcessor extends ExecutionProcessor { @@ -23,8 +24,9 @@ export class StepExecutionProcessor extends ExecutionProcessor { result.setFailed(false); const mi = registry.get(req.getParsedsteptext()); const params = req.getParametersList().map((item) => { - return item.getValue() ? item.getValue() : (item.getTable() as ProtoTable).toObject(); + return this.isTable(item) ? Table.from(item.getTable() as ProtoTable) : item.getValue(); }); + const method = mi.getMethod() as CommonFunction; try { @@ -57,6 +59,11 @@ export class StepExecutionProcessor extends ExecutionProcessor { return result; } + private isTable(item: Parameter): boolean { + return item.getParametertype() === Parameter.ParameterType.TABLE || + item.getParametertype() === Parameter.ParameterType.SPECIAL_TABLE; + } + private executionError(message: string): ExecutionStatusResponse { const result = new ProtoExecutionResult(); diff --git a/src/public/Table.ts b/src/public/Table.ts new file mode 100644 index 0000000..f8347e1 --- /dev/null +++ b/src/public/Table.ts @@ -0,0 +1,84 @@ +import { ProtoTable } from "../gen/spec_pb"; +import { TableRow } from "./TableRow"; + +export class Table { + + private readonly _headers: string[]; + private readonly _tableRows: TableRow[]; + private readonly _rows: string[][]; + + public static from(table: ProtoTable): Table { + if (!table.getHeaders()) { + throw new Error('Invalid table passed'); + } + const header = table.getHeaders(); + const gaugeTable = new Table(header?.getCellsList() ?? []); + + table.getRowsList().forEach((row) => { + gaugeTable.addRow(row.getCellsList()); + }); + + return gaugeTable; + } + + constructor(headers: string[]) { + this._headers = headers; + this._rows = new Array>(); + this._tableRows = new Array(); + } + + /** + * @deprecated Use getTableRows() instead. + * @public + */ + public get rows(): Array { + console.warn('.rows accessor is deprecated. Use .getTableRows() instead.'); + + return this._tableRows; + } + + public addRow(row: Array): void { + if (row.length != this._headers.length) { + throw new Error(`Row size mismatch. Expected row size: ${this._headers.length}.` + + `Obtained row size: ${row.length}.`); + } + this._rows.push(row); + const tableRow = new TableRow(); + + for (const header of this._headers) { + tableRow.addCell(header, row[this._headers.indexOf(header)]); + } + this._tableRows.push(tableRow); + } + + public getColumnNames(): Array { + return this._headers; + } + + public getColumnName(index: number): string { + if (index < 0 || index >= this._headers.length) { + throw new Error(`Column with index ${index} not found. Actual column size: ${this._headers.length}.`); + } + + return this._headers[index]; + } + + public getTableRows(): TableRow[] { + return this._tableRows; + } + + public getColumnValues(columnName: string): Array { + const i = this._headers.indexOf(columnName); + + return this.getColumnValuesForIndex(i); + } + + public getColumnValuesForIndex(index: number): string[] { + if (index >= 0) { + return this._rows.map((row) => row[index]); + } + + return []; + } + +} \ No newline at end of file diff --git a/src/public/TableRow.ts b/src/public/TableRow.ts new file mode 100644 index 0000000..8275347 --- /dev/null +++ b/src/public/TableRow.ts @@ -0,0 +1,37 @@ +export class TableRow { + + private readonly _cells: Map; + + constructor() { + this._cells = new Map(); + } + + public addCell(header: string, value: string): void { + this._cells.set(header, value); + } + + public getCell(columnName: string): string { + return this._cells.has(columnName) + ? this._cells.get(columnName) as string + : ''; + } + + public getCellValues(): Array { + return Array.from(this._cells.values()); + } + + public get size(): number { + return this._cells.size; + } + + /** + * @deprecated Use getCellValues() instead. + * @public + */ + public get cells(): Array { + console.warn('.cells accessor is deprecated. Use .getCellValues() instead.'); + + return Array.from(this._cells.values()); + } + +} \ No newline at end of file diff --git a/tests/RunnerServiceImplTests.ts b/tests/RunnerServiceImplTests.ts index 50bd08b..5de643a 100644 --- a/tests/RunnerServiceImplTests.ts +++ b/tests/RunnerServiceImplTests.ts @@ -457,7 +457,7 @@ describe('RunnerServiceImpl', () => { }); describe('.killProcess', () => { - it('should give a step info', () => { + it('should give a step info', (done) => { const s = new Server(); handler = new RunnerServiceImpl(s, new StaticLoader()); @@ -467,7 +467,10 @@ describe('RunnerServiceImpl', () => { handler.kill(createMock>({ request: req }), (err: error) => { expect(err).toBe(null); - expect(mockShutdown).toHaveBeenCalled(); + setTimeout(() => { + expect(mockShutdown).toHaveBeenCalled(); + done(); + }, 110); }); }); }); diff --git a/tests/processors/StepExecutionProcessorTests.ts b/tests/processors/StepExecutionProcessorTests.ts index 5dc1b79..186701c 100644 --- a/tests/processors/StepExecutionProcessorTests.ts +++ b/tests/processors/StepExecutionProcessorTests.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-function */ -import { equal } from 'assert'; +import { strictEqual } from 'assert'; import { ExecuteStepRequest } from '../../src/gen/messages_pb'; -import { Parameter, ProtoTable } from '../../src/gen/spec_pb'; +import { Parameter, ProtoTable, ProtoTableRow } from '../../src/gen/spec_pb'; import registry from '../../src/models/StepRegistry'; import { StepRegistryEntry } from '../../src/models/StepRegistryEntry'; import { StepExecutionProcessor } from '../../src/processors/StepExecutionProcessor'; @@ -66,8 +66,17 @@ describe('StepExecutionProcessor', () => { p1.setParametertype(Parameter.ParameterType.STATIC); const p2 = new Parameter(); + const table = new ProtoTable(); + const row1 = new ProtoTableRow(); + + row1.setCellsList(["header"]); + const row2 = new ProtoTableRow(); + + row2.setCellsList(["value"]); + table.setHeaders(row1); + table.setRowsList([row2]); p2.setName("table"); - p2.setTable(new ProtoTable()); + p2.setTable(table); p2.setParametertype(Parameter.ParameterType.TABLE); const req = new ExecuteStepRequest(); @@ -89,7 +98,7 @@ describe('StepExecutionProcessor', () => { process.env.screenshot_on_failure = 'false'; registry.isImplemented = jest.fn().mockReturnValue(true); - const method = () => { equal(1, 2); }; + const method = () => { strictEqual(1, 2); }; registry.get = jest.fn().mockReturnValue(new StepRegistryEntry('hello', 'hello', 'StepImpl.ts', method)); registry.getContinueOnFailureFunctions = jest.fn().mockReturnValue(['AssertionError']); @@ -104,7 +113,7 @@ describe('StepExecutionProcessor', () => { const result = resMess.getExecutionresult(); expect(result?.getFailed()).toBe(true); - expect(result?.getErrormessage()).toBe('1 == 2'); + expect(result?.getErrormessage()).toContain('1 !== 2'); expect(result?.getRecoverableerror()).toBe(true); expect(capture).toBeCalledTimes(0); }); diff --git a/tests/public/TableTests.ts b/tests/public/TableTests.ts new file mode 100644 index 0000000..6a8f450 --- /dev/null +++ b/tests/public/TableTests.ts @@ -0,0 +1,88 @@ +import { ProtoTable, ProtoTableRow } from '../../src/gen/spec_pb'; +import { Table } from '../../src/public/Table'; + +describe('Table', () => { + describe('.from', () => { + it('should throw error for invalid prototable', () => { + const protoTable = new ProtoTable(); + + expect(() => { Table.from(protoTable); }).toThrowError('Invalid table passed'); + }); + + it('should throw error for given prototable', () => { + const protoTable = new ProtoTable(); + const headers = new ProtoTableRow(); + + headers.setCellsList(["name"]); + const row1 = new ProtoTableRow(); + + row1.setCellsList(["gauge"]); + protoTable.setHeaders(headers); + protoTable.setRowsList([row1]); + + expect(Table.from(protoTable).rows[0].cells).toStrictEqual(["gauge"]); + }); + }); + + describe('.addRow', () => { + it('should add arow to table', () => { + const table = new Table(["name"]); + + table.addRow(["gauge"]); + expect(table.getTableRows()[0].getCell("name")).toStrictEqual("gauge"); + }); + + it('should throw error for mismatched row size', () => { + const table = new Table(["name"]); + + expect(() => { table.addRow(["gauge", "foo"]); }).toThrowError("Row size mismatch."); + }); + }); + + describe('.getColumnName', () => { + it('should get the column name for given index', () => { + const table = new Table(["name"]); + + expect(table.getColumnName(0)).toStrictEqual("name"); + }); + + it('should trow error invalid index', () => { + const table = new Table(["name"]); + + expect(() => { table.getColumnName(2); }).toThrowError("Column with index 2 not found. Actual column size: 1."); + }); + }); + describe('.getColumnNames', () => { + it('should give all the headers', () => { + const table = new Table(["name"]); + + expect(table.getColumnNames()).toStrictEqual(["name"]); + }); + }); + + describe('.getColumnValues', () => { + it('should give all values for given column name', () => { + const table = new Table(["name"]); + + table.addRow(["gauge"]); + expect(table.getColumnValues("name")).toStrictEqual(["gauge"]); + }); + + it('should give empty list for non existing column name', () => { + const table = new Table(["name"]); + + table.addRow(["gauge"]); + expect(table.getColumnValues("foo")).toStrictEqual([]); + }); + }); + + describe('.getTableRows', () => { + it('should give all table rows', () => { + const table = new Table(["name"]); + + table.addRow(["gauge"]); + expect(table.getTableRows()[0].getCellValues()).toStrictEqual(["gauge"]); + expect(table.getTableRows()[0].size).toStrictEqual(1); + }); + }); +}); \ No newline at end of file diff --git a/tests/screenshot/ScreenshotTest.ts b/tests/screenshot/ScreenshotTest.ts index 799a7a9..d9fc57d 100644 --- a/tests/screenshot/ScreenshotTest.ts +++ b/tests/screenshot/ScreenshotTest.ts @@ -1,5 +1,4 @@ import { existsSync, unlinkSync } from 'fs'; -import { tmpdir } from 'os'; import { Screenshot } from '../../src/screenshot/Screenshot'; import { Util } from '../../src/utils/Util'; @@ -8,11 +7,6 @@ describe('Screenshot', () => { let screenshotFile: string; describe('.capture', () => { - - beforeAll(() => { - process.env.gauge_screenshots_dir = tmpdir(); - }); - afterEach(() => { if (existsSync(screenshotFile)) { unlinkSync(screenshotFile); diff --git a/ts.json b/ts.json index 5a86163..c823b75 100644 --- a/ts.json +++ b/ts.json @@ -34,6 +34,6 @@ "--start" ] }, - "version": "0.2.0", + "version": "0.1.0", "gRPCSupport": true } \ No newline at end of file