Skip to content

awilliams-qcells/cucumber-typescript-example

 
 

Repository files navigation

Cucumber & Typescript Example

cucumber tests

unit tests

Goal

The goal of this example is to write and test code to compute the value of a wallet containing different currencies in a given currency in typescript. We will run mocha and cucumber/gherkin unit tests on this code.

Choosen language: typescript
Written and tested on nodejs: v12.22.6 aka. lts/erbium

Steps

1 - Install dependencies

npm install

2 - Add the Api Key for echange rates

Go to https://exchangeratesapi.io/, create an account and then copy the api key in a .env at the root of the project such as:

API_KEY=74f1cf.....

3 - Scripts

npm run build builds the ts into js to ./build

npm run test:unit launches unit tests

npm run test:cucumber launches cucumber tests on the features in ./features/...

Prototype:

async function computeWalletValue(wallet: Wallet, returnValueCurrency: Currencies = Currencies.EUR, date: string = 'latest'): Promise<number>

Possible currencies: CAD HKD ISK PHP DKK HUF CZK AUD RON SEK IDR INR BRL RUB HRK JPY THB CHF SGD PLN BGN TRY CNY NOK NZD ZAR USD MXN ILS GBP KRW MYR

Check-out our unit test: ./test/test.js, for an example of how to call the function or run it by using npm run test:unit

About

Cucumber & Typescript example project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 55.6%
  • Gherkin 36.1%
  • JavaScript 8.3%