Skip to content

Commit

Permalink
Add functional tests
Browse files Browse the repository at this point in the history
Signed-off-by: Zabil Cheriya Maliackal <[email protected]>

Use workspace and add functional tests

Signed-off-by: Zabil Cheriya Maliackal <[email protected]>

Remove java file

Signed-off-by: Zabil Cheriya Maliackal <[email protected]>

Add common build tasks

Signed-off-by: Zabil Cheriya Maliackal <[email protected]>

Add implementation

Signed-off-by: Zabil Cheriya Maliackal <[email protected]>
  • Loading branch information
zabil committed Jun 10, 2024
1 parent affce42 commit bd8a06d
Show file tree
Hide file tree
Showing 104 changed files with 3,943 additions and 558 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: npm install and test
run: |
npm install
npm test
npm test -w gauge-ts
env:
CI: true

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ deploy/
artifacts/
*.tgz
.zed
.gauge
logs
reports
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run precommit
npm run precommit -w gauge-ts
6 changes: 6 additions & 0 deletions e2e/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Language": "ts",
"Plugins": [
"html-report"
]
}
17 changes: 17 additions & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "e2e",
"description": "Starter template for writing TypeScript tests for Gauge",
"scripts": {
"test": "gauge run specs"
},
"dependencies": {
"gauge-ts": "*",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
},
"devDependencies": {
"@getgauge/cli": "latest",
"@types/node": "latest",
"taiko": "^1.4.0"
}
}
32 changes: 32 additions & 0 deletions e2e/specs/example.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Specification Heading

This is an executable specification file. This file follows markdown syntax.
Every heading in this file denotes a scenario. Every bulleted point denotes a step.

To execute this specification, run
gauge run specs


* Vowels in English language are "aeiou".

## Vowel counts in single word

tags: single word

* The word "gauge" has "3" vowels.


## Vowel counts in multiple word

This is the second scenario in this specification

Here's a step that takes a table

* Almost all words have vowels
|Word |Vowel Count|
|------|-----------|
|Gauge |3 |
|Mingle|2 |
|Snap |1 |
|GoCD |1 |
|Rhythm|0 |
30 changes: 30 additions & 0 deletions e2e/tests/implementation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as assert from "node:assert";
import { DataStoreFactory, Step, type Table } from "gauge-ts";

class Implementation {
static vowelsCount = (word: string): number => {
const vowels = DataStoreFactory.getSpecDataStore().get(
"vowels",
) as string[];
return word.split("").filter((c) => vowels.includes(c)).length;
};

@Step("Vowels in English language are <aeiou>.")
public async listVowels(vowels: string) {
DataStoreFactory.getSpecDataStore().put("vowels", vowels.split(""));
}

@Step("The word <gauge> has <3> vowels.")
public async checkWord(word: string, count: string) {
assert.equal(Implementation.vowelsCount(word), Number.parseInt(count));
}

@Step("Almost all words have vowels <table>")
public async checkTableOfWords(table: Table) {
for (const row of table.getTableRows()) {
const word = row.getCell("Word");
const count = row.getCell("Vowel Count");
assert.equal(Implementation.vowelsCount(word), Number.parseInt(count));
}
}
}
21 changes: 21 additions & 0 deletions e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "ES6",
"lib": [
"esnext"
],
"declaration": true,
"outDir": "./dist",
"strict": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true
},
"include": [
"tests/**/*",
"gen/**/*"
],
"exclude": [
"node_modules/"
]
}
File renamed without changes.
4 changes: 1 addition & 3 deletions build.sh → gauge-ts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ function version() {
function package() {
checkCommand "npm"
checkCommand "zip"
rm -rf dist deploy artifacts
npm run build
cp -r ./src/gen ./dist
npm run clean:build
mkdir -p deploy
cp launcher.* deploy
cp ts.json deploy
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions gauge-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "gauge-ts",
"version": "0.3.0",
"description": "Typescript runner for Gauge",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"lint": "biome lint . --apply",
"check": "biome ci .",
"format": "biome format . --write",
"prebuild": "npm run lint",
"preclean:build": "rimraf dist deploy artifacts",
"build": "tsc",
"clean:build": "npm run build",
"postbuild": "copyup -a ./src/gen/** ./dist",
"precommit": " npm run format && npm run lint",
"test": "jest --verbose --detectOpenHandles --forceExit",
"gen-proto": "sh genproto.sh",
"prepublishOnly": "tsc",
"prepare": "husky"
},
"repository": {
"type": "git",
"url": "git+https://github.com/getgauge/gauge-ts.git"
},
"keywords": ["gauge", "Acceptance Test", "Typescript", "Automation"],
"author": "Gauge <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/getgauge/gauge-ts/issues"
},
"dependencies": {
"@grpc/grpc-js": "^1.10.8",
"google-protobuf": "^3.13.0",
"ts-node": "^10.9.0",
"typescript": "^5.0.4",
"uuid": "^8.3.0"
},
"devDependencies": {
"copyfiles": "2.4.1",
"@biomejs/biome": "1.7.3",
"@types/google-protobuf": "^3.7.3",
"@types/jest": "^24.9.1",
"@types/uuid": "^8.3.0",
"grpc_tools_node_protoc_ts": "^5.3.3",
"grpc-tools": "^1.12.4",
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-mock-process": "^2.0.0",
"jest-silent-reporter": "^0.6.0",
"ts-jest": "^29.1.4"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions gauge-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"lib": ["es2023"],
"declaration": true,
"outDir": "./dist",
"strict": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"plugins": [
{
"cacheBetweenTests": false
}
]
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
Binary file removed launcher
Binary file not shown.
Loading

0 comments on commit bd8a06d

Please sign in to comment.