Skip to content

Commit

Permalink
🔖 improvement (#16)
Browse files Browse the repository at this point in the history
* ➖ remove register feature

* 📚 update README content

* 📚 add korean localisation

* 💄 npx cli
  • Loading branch information
depapp authored Jul 27, 2022
1 parent caffb81 commit ea45e4e
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 79 deletions.
40 changes: 36 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,50 @@

# pusakatest

<img width="682" alt="image" src="https://user-images.githubusercontent.com/6134774/181021798-15d57ebd-63c2-4925-90cc-5ae607cd272b.png">
[![asciicast](https://asciinema.org/a/511165.svg)](https://asciinema.org/a/511165)

## :bulb: how to use
you can simply run this command
## :gear: setup
- make sure `nodejs` and `npm` is already installed. you can verify it using these commands
```bash
node -v
```
```bash
npm -v
```
- you can create new folder/directory to setup `pusakatest` and don't forget to change the folder/directory location. for example
```bash
mkdir hello-pusakatest && cd hello-pusakatest
```
- to setup `pusakatest`, you can simply run this command (and follow the instructions)
```bash
npx pusakatest
```
nothing else after that, just run it!
- nothing else after that, just run it!
```bash
npm run test
```
- if you want to publish the file report to [Cucumber Reports](https://reports.cucumber.io), just use
```bash
npm run test-publish
```

## :bulb: writing feature script
- to create new feature script, just add `.feature` file under `/features` folder/directory
- after that, just re-run it
```bash
npm run test
```
- example:
```gherkin
Feature: API REQRES.IN
Scenario: Get all users list on REQRES.IN API
Given I make a "POST" request to "https://reqres.in/api/users"
When I receive a response
Then I expect response should have a status "200"
```

## :bookmark: credits
- [pactum-cucumber-boilerplate](https://github.com/pactumjs/pactum-cucumber-boilerplate)
- [Dominik Kundel](https://www.twilio.com/blog/how-to-build-a-cli-with-node-js)
- [old-README](https://github.com/depapp/pusakatest/tree/0af4d1c0a0ce712fd2380f8de50b1562134468e4#readme)
2 changes: 1 addition & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function promptForMissingOptions(options) {
type: 'list',
name: 'template',
message: 'what language/localisation do you want to use?',
choices: ['indonesian', 'english'],
choices: ['indonesian', 'english', 'korean'],
default: defaultTemplate,
});
}
Expand Down
37 changes: 0 additions & 37 deletions templates/english/features/example-authentication.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,6 @@ Feature: Authentication on ADEQUATESHOP API

API Automation with Authentication example

Scenario: User Registration using Valid Data
Given I make a "POST" request to "http://restapi.adequateshop.com/api/authaccount/registration"
And I use random test data to create an account
When I receive a response
Then I expect response should have a status "200"
And I expect response should have a json schema
"""
{
"type": "object",
"properties": {
"code": {
"type": "integer"
},
"message": {
"type": "string"
},
"data": {
"type": "object",
"properties": {
"Id": {
"type": "integer"
},
"Name": {
"type": "string"
},
"Email": {
"type": "string"
},
"Token": {
"type": "string"
}
}
}
}
}
"""

Scenario: User Registration using Registered Data
Given I make a "POST" request to "http://restapi.adequateshop.com/api/authaccount/registration"
And I set body to
Expand Down
37 changes: 0 additions & 37 deletions templates/indonesian/features/contoh-autentikasi.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,6 @@ Fitur: Autentikasi pada ADEQUATESHOP API

Contoh Automation API untuk fitur Autentikasi

Skenario: Registrasi Pengguna Baru Menggunakan Data Yang Sah (Valid)
Dengan Saya melakukan metode "POST" request pada "http://restapi.adequateshop.com/api/authaccount/registration"
Dan Saya menggunakan data test acak
Ketika Saya menerima sebuah response API
Maka Saya mengharapkan status code response API nya "200"
Dan Saya mengharapkan response API nya memiliki schema json
"""
{
"type": "object",
"properties": {
"code": {
"type": "integer"
},
"message": {
"type": "string"
},
"data": {
"type": "object",
"properties": {
"Id": {
"type": "integer"
},
"Name": {
"type": "string"
},
"Email": {
"type": "string"
},
"Token": {
"type": "string"
}
}
}
}
}
"""

Skenario: Registrasi Pengguna Baru Menggunakan Data Yang Sudah Ada
Dengan Saya melakukan metode "POST" request pada "http://restapi.adequateshop.com/api/authaccount/registration"
Dan Saya set data untuk body menggunakan
Expand Down
6 changes: 6 additions & 0 deletions templates/korean/config/cucumber.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default": {
"language": "ko",
"format": ["summary", "html:cucumber-report.html"]
}
}
6 changes: 6 additions & 0 deletions templates/korean/features/support/defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { request, settings } = require('pactum')
const { Before } = require('@cucumber/cucumber')

Before(() => {
settings.setReporterAutoRun(false)
})
24 changes: 24 additions & 0 deletions templates/korean/features/support/steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const pactum = require('pactum')
const { Given, When, Then, Before, After } = require('@cucumber/cucumber')

let spec = pactum.spec()

Before(() => {
spec = pactum.spec()
})

Given(/^ "(.*)" "(.*)"$/, function (method, endpoint) {
spec[method.toLowerCase()](endpoint)
})

When('나는 응답을 받는다', async function () {
await spec.toss()
})

Then('응답에 상태가 있어야 합니다. "{int}"', function (code) {
spec.response().should.have.status(code)
})

After(() => {
spec.end()
})
6 changes: 6 additions & 0 deletions templates/korean/features/예시.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
기능: API REQRES.IN

시나리오: 모든 사용자 목록 가져오기 API REQRES.IN
조건 나는 만든다 "GET" 요청하다 "https://reqres.in/api/users"
만일 나는 응답을 받는다
그러면 응답에 상태가 있어야 합니다. "200"
26 changes: 26 additions & 0 deletions templates/korean/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "pusakatest",
"version": "2.0.1",
"description": "pusakatest is an automation testing tool based on pactum using bdd (cucumber) style",
"main": "index.js",
"scripts": {
"test": "cucumber-js --config config/cucumber.json",
"test-publish": "cucumber-js --config config/cucumber.json --publish"
},
"repository": {
"type": "git",
"url": "git+https://github.com/depapp/pusakatest.git"
},
"author": "@depapp",
"license": "ISC",
"bugs": {
"url": "https://github.com/depapp/pusakatest/issues"
},
"homepage": "https://github.com/depapp/pusakatest#readme",
"devDependencies": {
"@cucumber/cucumber": "^8.5.0",
"@faker-js/faker": "^7.3.0",
"mocha": "^10.0.0",
"pactum": "^3.1.13"
}
}

0 comments on commit ea45e4e

Please sign in to comment.