Skip to content

Commit

Permalink
readme update, in launchers script text to file.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkitsunai committed Mar 25, 2024
1 parent daf90c8 commit fbe460b
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 109 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ jobs:
env:
CI: true

# - name: Update coverage
# run: |
# npm run codecov -- -t ${{ secrets.CODECOV_TOKEN }}

build-artifacts:
needs: test
runs-on: ubuntu-latest
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Gauge for TypeScript

<!-- [![Actions Status](https://github.com/bugdiver/gauge-ts/workflows/Node%20CI/badge.svg)](https://github.com/BugDiver/gauge-ts/actions)
[![npm version](https://badge.fury.io/js/gauge-ts.svg)](https://badge.fury.io/js/gauge-ts) -->
![GHA](https://github.com/tkitsunai/gauge-typescript/actions/workflows/nodejs.yml/badge.svg)
[![NPM](https://img.shields.io/npm/v/gauge-typescript.svg?style=flat-square)](https://www.npmjs.com/package/gauge-typescript)

This project adds TypeScript [language plugin](https://docs.gauge.org/latest/installation.html#language-runner) for [Gauge](http://gauge.org).

The plugin is authored in [TypeScript](https://en.wikipedia.org/wiki/TypeScript).

[!NOTE]
This project was forked from gauge-ts to continuously maintain gauge-typescript. Therefore, to update to a new version of gauge-typescript, you will need to install it from the source code. If you need further support, please feel free to contact us.

## Getting started

API Reference: https://tkitsunai.github.io/gauge-typescript
Expand Down Expand Up @@ -47,5 +50,3 @@ To install the the typescript plugin use(Note, this will uninstall gauge-ts befo
````
./build.sh | .\build.ps1 package
````

New distribution details need to be updated in the dotnet-install.json file in [gauge plugin repository](https://github.com/getgauge/gauge-repository) for a new verison update.
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function package() {
pnpm build
cp -r ./src/gen ./dist
mkdir -p deploy
cp -r scripts/* deploy
cp launcher.* deploy
cp typescript.json deploy
mkdir -p artifacts
Expand Down
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// GENERAL
// -----------------------------------------------------------------
name: 'Gauge Typescript',
repo: 'https://github.com/bugdiver/gauge-ts',
repo: 'https://github.com/tkitsunai/gauge-typescript',
homepage: 'index.md',
loadSidebar: 'sidebar.md',
auto2top: true,
Expand All @@ -41,7 +41,7 @@
},
plugins: [
EditOnGithubPlugin.create(
'https://github.com/bugdiver/gauge-ts/blob/master/docs/'
'https://github.com/tkitsunai/gauge-typescript/blob/master/docs/'
)
]
};
Expand Down
101 changes: 49 additions & 52 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Gauge for TypeScript
[![NPM](https://img.shields.io/npm/v/gauge-ts.svg?style=flat-square)](https://www.npmjs.com/package/gauge-ts)
[![codecov](https://codecov.io/gh/BugDiver/gauge-ts/branch/master/graph/badge.svg)](https://codecov.io/gh/BugDiver/gauge-ts)
[![Build Status](https://dev.azure.com/bugdiver/gauge-ts/_apis/build/status/BugDiver.gauge-ts?branchName=master)](https://dev.azure.com/bugdiver/gauge-ts/_build/latest?definitionId=1&branchName=master)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://github.com/BugDiver/gauge-ts/blob/master/LICENSE)
<a class="github-button" href="https://github.com/bugdiver/gauge-ts" data-icon="octicon-star" data-show-count="true" aria-label="Star bugdiver/gauge-ts on GitHub">Star</a>
[![NPM](https://img.shields.io/npm/v/gauge-typescript.svg?style=flat-square)](https://www.npmjs.com/package/gauge-typescript)
![GHA](https://github.com/tkitsunai/gauge-typescript/actions/workflows/nodejs.yml/badge.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://github.com/tkitsunai/gauge-typescript/blob/master/LICENSE)
<a class="github-button" href="https://github.com/tkitsunai/gauge-typescript" data-icon="octicon-star" data-show-count="true" aria-label="Star tkitsunai/gauge-typescript on GitHub">Star</a>

A [TypeScript](https://www.typescriptlang.org/) runner for [Gauge](https://gauge.org).

Expand All @@ -12,6 +11,7 @@ A [TypeScript](https://www.typescriptlang.org/) runner for [Gauge](https://gauge
This projects adds support for implementing your Gauge acceptance tests in typescript language. Here are the few motivations
* https://github.com/getgauge/gauge/issues/293
* https://github.com/getgauge/gauge-js/issues/187
* Ongoing updates to dependency libraries

## Features

Expand All @@ -31,44 +31,39 @@ While it is possible to download dependency components using npm, we recommend u
The plugin has two components which has to install to run a gauge typescript project.
The first component is in form of a gauge plugin which take care of create a gauge-ts project and starting the runner.

The 2nd component is a `npm` package which gives the API which the users will use to write there step/hook implementations. The second component will be install as part of `npm install` in your gauge typescript project.
The 2nd component is a `npm` package which gives the API which the users will use to write there step/hook implementations. The second component will be install as part of `npm install`or`pnpm install` in your gauge typescript project.

To install the first component

```bash
gauge install ts
```

or download the `zip` file from [Github Release](https://github.com/BugDiver/gauge-ts/releases) and run
or download the `zip` file from [Github Release](https://github.com/tkitsunai/gauge-typescript/releases) and run

```
gauge install ts -f {location_of_zip_file}
gauge install typescript -f {location_of_zip_file}
```

## Create a Project

Once you have installed the `gauge-ts` plugin, you can create a sample app. To verify your installation run
Once you have installed the `gauge-typescript` plugin, you can create a sample app. To verify your installation run

```bash
gauge -v
```
The output should contain

`ts (VERSION_OF_PLUGIN)`
`typescript (VERSION_OF_PLUGIN)`

Now you can run the following command to create a sample project in a empty dir (create a new one for your test project)
```bash
gauge init ts
gauge init https://github.com/tkitsunai/gauge-template-typescript/archive/refs/tags/v0.1.1.zip
```

## Run a Project

Once the initialization is done run `npm install` to get all the required dependencies.
Once the initialization is done run `npm install`or`pnpm install` to get all the required dependencies.
Now you can run `gauge run specs` to run your project.
Open the project in your favorite editor and start adding some new tests.


## APIS
## APIs

NOTE: All the classes containing step/hook implementations needs to be exported as `default`.

Expand All @@ -79,7 +74,7 @@ NOTE: All the classes containing step/hook implementations needs to be exported
**Syntax**

```typescript
import {Step} from 'gauge-ts';
import {Step} from 'gauge-typescript';
export default class StepImpl {

@Step("Hello <world>")
Expand All @@ -93,7 +88,7 @@ export default class StepImpl {

**aliases**
```typescript
import {Step} from 'gauge-ts';
import {Step} from 'gauge-typescript';
export default class StepImpl {

@Step(["Hello <world>", "Hi <world>"])
Expand All @@ -110,7 +105,7 @@ export default class StepImpl {
#### Suite Hooks

```typescript
import {BeforeSuite, AfterSuite} from 'gauge-ts';
import {BeforeSuite, AfterSuite} from 'gauge-typescript';
export default class StepImpl {

@BeforeSuite()
Expand All @@ -129,7 +124,7 @@ export default class StepImpl {
#### Spec Hooks

```typescript
import {BeforeSpec, AfterSpec} from 'gauge-ts';
import {BeforeSpec, AfterSpec} from 'gauge-typescript';
export default class StepImpl {

@BeforeSpec()
Expand All @@ -148,7 +143,7 @@ export default class StepImpl {
#### Scenario Hooks

```typescript
import {BeforeScenario, AfterScenario} from 'gauge-ts';
import {BeforeScenario, AfterScenario} from 'gauge-typescript';
export default class StepImpl {

@BeforeScenario()
Expand All @@ -167,7 +162,7 @@ export default class StepImpl {
#### Step Hooks

```typescript
import {BeforeStep, AfterStep} from 'gauge-ts';
import {BeforeStep, AfterStep} from 'gauge-typescript';
export default class StepImpl {

@BeforeStep()
Expand All @@ -188,8 +183,8 @@ export default class StepImpl {
Gauge allows to control the execution by running filtered hooks using `tags`.


```javascript
import {BeforeSpec} from 'gauge-ts';
```typescript
import {BeforeSpec} from 'gauge-typescript';
export default class StepImpl {

@BeforeSpec({tags: ["ready"]})
Expand All @@ -203,8 +198,8 @@ export default class StepImpl {
You can use operators as well to filter hooks


```javascript
import {BeforeSpec, BeforeScenario, Operator} from 'gauge-ts';
```typescript
import {BeforeSpec, BeforeScenario, Operator} from 'gauge-typescript';
export default class StepImpl {

@BeforeSpec({tags: ["ready", "done"], operator: Operator.And})
Expand All @@ -227,8 +222,8 @@ NOTE: `tags` are not applicable for `<Before | After>Suite` hooks.
To get additional information about the current specification, scenario and step executing, an additional ExecutionContext parameter can be added to the hooks method.


```javascript
import {BeforeStep, AfterStep, ExecutionContext, Scenario, StepInfo} from 'gauge-ts';
```typescript
import {BeforeStep, AfterStep, ExecutionContext, Scenario, StepInfo} from 'gauge-typescript';
export default class StepImpl {

@BeforeStep()
Expand Down Expand Up @@ -261,9 +256,9 @@ This data store keeps values added to it during the life cycle of entire suite e

WARNING: `SuiteStore` is not advised to be used when executing specs in parallel. The values are not retained between parallel streams of execution.

```javascript
```typescript
// import factory
import {DataStoreFactory, DataStore} from 'gauge-ts';
import {DataStoreFactory, DataStore} from 'gauge-typescript';

// Adding value
let suiteStore: DataStore = DataStoreFactory.getSuiteDataStore();
Expand All @@ -279,9 +274,9 @@ String elementId = suiteStore.get("element-id") as string;

This data store keeps values added to it during the life cycle of the specification execution. Values are cleared after every specification executes.

```javascript
```typescript
// import factory
import {DataStoreFactory, DataStore} from 'gauge-ts';
import {DataStoreFactory, DataStore} from 'gauge-typescript';

// Adding value
let specStore: DataStore = DataStoreFactory.getSpecDataStore();
Expand All @@ -297,9 +292,9 @@ String elementId = specStore.get("element-id") as string;

This data store keeps values added to it in the life cycle of the scenario execution. Values are cleared after every scenario executes.

```javascript
```typescript
// import factory
import {DataStoreFactory, DataStore} from 'gauge-ts';
import {DataStoreFactory, DataStore} from 'gauge-typescript';

// Adding value
let scenarioStore: DataStore = DataStoreFactory.getSpecDataStore();
Expand All @@ -314,11 +309,11 @@ String elementId = scenarioStore.get("element-id") as string;
### Custom Screenshots

* By default gauge captures the display screen on failure if this feature has been enabled.
If you need to take CustomScreenshots (using webdriver for example) because you need only a part of the screen captured, this can be done by assigning a `CustomScreenshotGrabber` to `gauge-ts`
If you need to take CustomScreenshots (using webdriver for example) because you need only a part of the screen captured, this can be done by assigning a `CustomScreenshotGrabber` to `gauge-typescript`

```javascript
```typescript
// import CustomScreenshotGrabber
import {CustomScreenGrabber} from 'gauge-ts';
import {CustomScreenGrabber} from 'gauge-typescript';

export default class ScreenGrabber {
@CustomScreenGrabber()
Expand All @@ -332,8 +327,8 @@ export default class ScreenGrabber {

DEPRECATION NOTICE: `CustomScreenshotGrabber` has been deprecated since gauge-ts v0.0.5, please use `CustomScreenshotWriter` as mentioned below

```javascript
import { CustomScreenshotWriter } from 'gauge-ts';
```typescript
import { CustomScreenshotWriter } from 'gauge-typescript';
import { join, basename } from 'path';

const { screenshot } = require('taiko');
Expand All @@ -358,9 +353,9 @@ Custom messages/data can be added to execution reports using the below API from

These messages will appear under steps in the execution reports.

```javascript
```typescript
// import the class
import {Gauge} from 'gauge-ts';
import {Gauge} from 'gauge-typescript';

// write messages
Gauge.writeMessage("Custom message for report");
Expand All @@ -371,9 +366,9 @@ Gauge.writeMessage("Custom message for report");
Custom screenshot can be added to execution reports using the below API from the step implementations or hooks.

These screenshots will appear under steps in the execution reports.
```javascript
```typescript
// import the class
import {Gauge} from 'gauge-ts';
import {Gauge} from 'gauge-typescript';

// write messages
await Gauge.captureScreenshot();
Expand All @@ -384,9 +379,9 @@ await Gauge.captureScreenshot();
The default behavior in gauge is to break execution on the first failure in a step. So, if the first step in a scenario fails, the subsequent steps are skipped. While this works for a majority of use cases, there are times when you need to execute all steps in a scenario irrespective of whether the previous steps have failed or not.

To address that requirement, gauge provides a way for language runners to mark steps as recoverable, depending on whether the step implementation asks for it explicitly. Each language runner uses different syntax, depending on the language idioms to allow a step implementation to be marked to continue on failure.
```javascript
```typescript
// import type
import {ContinueOnFailure} from 'gauge-ts';
import {ContinueOnFailure} from 'gauge-typescript';

// The ``@ContinueOnFailure`` decorator tells Gauge to continue executing other
// steps even if the current step fails.
Expand All @@ -403,9 +398,9 @@ export default class StepImplementation {

Continue on Failure can take an optional parameter to specify the list of error classes on which it would continue to execute further steps in case of failure. This is currently supported only with the following runners.

```javascript
```typescript
// import type
import {ContinueOnFailure} from 'gauge-ts';
import {ContinueOnFailure} from 'gauge-typescript';
export default class StepImpl {
@ContinueOnFailure(['AssertionError', 'CustomError'])
@Step("hello")
Expand Down Expand Up @@ -479,16 +474,18 @@ This will change all spec files to reflect the change.

Gauge supports [LSP](https://blog.getgauge.io/gauge-and-the-language-server-protocol-c56fbcfba177) which can be used to used to integrate Gauge with any (if it supports) LSP. Gauge has it's official plugin for [Visual Studio Code](https://github.com/getgauge/gauge-vscode/blob/master/README.md) which allows author/debug to write their tests in multiple language.

Gauge-Ts follows the protocol and implements the apis required by gauge to support a language. Install the `gauge` plugin for VS Code for a rich editing and debugging support with Gauge and Typescript.
Gauge-TypeScript follows the protocol and implements the apis required by gauge to support a language. Install the `gauge` plugin for VS Code for a rich editing and debugging support with Gauge and Typescript.


## Contact & Support

- Create a [Github issue](https://github.com/bugdiver/gauge-ts/issues) for bug reports, feature requests, or questions
- Add a ⭐️ [star on GitHub](https://github.com/bugdiver/gauge-ts) or ❤️ [tweet](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2Fbugdiver%2Fgauge-ts&via=bugdiverr&hashtags=getgauge,automation,bdd,typescript) to support the project!
- Create a [Github issue](https://github.com/tkitsunai/gauge-typescript/issues) for bug reports, feature requests, or questions
- Add a ⭐️ [star on GitHub](https://github.com/tkitsunai/gauge-typescript) or ❤️ [tweet](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2Ftkitsunai%2Fgauge-typescript&via=tkitsunai&hashtags=getgauge,automation,bdd,typescript) to support the project!

## License

Maintain by [@tkitsunai](https://twitter.com/tkitsunai)

This repository forked by [@BugDiver:gauge-ts](https://github.com/bugdiver/gauge-ts/)

This project is licensed under the MIT License.
Expand Down
6 changes: 3 additions & 3 deletions docs/sidebar.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- [Documentation](/)
- **Links**
- [![Github](https://icongram.jgog.in/simple/github.svg?color=808080&size=16)Github](https://github.com/bugdiver/gauge-ts)
- [![NPM](https://icongram.jgog.in/simple/npm.svg?colored&size=16)NPM](https://www.npmjs.com/package/gauge-ts)
- [![Twitter](https://icongram.jgog.in/simple/twitter.svg?colored&size=16)@bugdiver](http://twitter.com/bugdiverr)
- [![Github](https://icongram.jgog.in/simple/github.svg?color=808080&size=16)Github](https://github.com/tkitsunai/gauge-typescript)
- [![NPM](https://icongram.jgog.in/simple/npm.svg?colored&size=16)NPM](https://www.npmjs.com/package/gauge-typescript)
- [![Twitter](https://icongram.jgog.in/simple/twitter.svg?colored&size=16)@bugdiver](http://twitter.com/tkitsunai)
12 changes: 7 additions & 5 deletions launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,18 @@ if (process.argv[2] === "--init") {

else if (process.argv[2] === "--start") {
var script = 'import { GaugeRuntime } from "gauge-typescript/dist/GaugeRuntime";'
+ `let runner = new GaugeRuntime();`
+ `const runner = new GaugeRuntime();`
+ `runner.start();`

const scriptContent = fs.readFileSync(path.join(__dirname, "runnerRuntime.ts"), { encoding: 'utf8' });

var opts = [
'-O', `{"experimentalDecorators": true,"emitDecoratorMetadata": true}`,
...hasModule('tsconfig-paths') ? ['-r', 'tsconfig-paths/register'] : [],
'-e', script
'-e', scriptContent
];
//let tsNode = path.join(GAUGE_PROJECT_ROOT, 'node_modules', '.bin', 'ts-node');
let tsxPath = path.join(GAUGE_PROJECT_ROOT, 'node_modules', '.bin', 'tsx');
var runner = cp.spawn(getCommand(tsxPath), opts, {
let tsNode = path.join(GAUGE_PROJECT_ROOT, 'node_modules', '.bin', 'ts-node');
var runner = cp.spawn(getCommand(tsNode), opts, {
env: process.env,
silent: false,
stdio: "inherit",
Expand Down
3 changes: 3 additions & 0 deletions scripts/runnerRuntime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { GaugeRuntime } from "gauge-typescript/dist/GaugeRuntime";
const runner = new GaugeRuntime();
runner.start();
Loading

0 comments on commit fbe460b

Please sign in to comment.