Skip to content

Commit

Permalink
fix: some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent committed Aug 7, 2023
1 parent 51893dd commit 042e84d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package

on:
push:
branches:
- master

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npx semantic-release
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,13 @@
"allure-patch": "^1.0.3",
"codeceptjs-expect": "^1.0.0",
"form-data": "^3.0.0"
},
"files": [
"stepObjects/*",
"README.md"
],
"repository": {
"type": "git",
"url": "https://github.com/kobenguyent/codeceptjs-rest-demo.git"
}
}
8 changes: 4 additions & 4 deletions src/GET_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ const { I } = inject();
Feature('GET tests');

Scenario('Verify a successful call', async () => {
await I.sendGetRequest('/api/users?page=2');
await I.getUserPerPage(2);
I.seeResponseCodeIsSuccessful();
I.seeResponseContainsJson({page:2,per_page:6})
});

Scenario('Verify a not found call', async () => {
I.sendGetRequest('/api/users/266');
await I.getUserById(266);
I.seeResponseCodeIsClientError();
});

Scenario('Verify getting a single user', async () => {
const res = await I.sendGetRequest('/api/users/2');
const res = await I.getUserById(2);
await I.expectEqual(res.data.data.id, 2);
});

Scenario('Verify getting list of users', async () => {
const res = await I.sendGetRequest('/api/users?page=2');
const res = await I.getUserPerPage(2);
await I.expectEqual(res.data.data[0].id, 7);
});
5 changes: 4 additions & 1 deletion stepObjects/custom.steps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import userSteps from './userSteps';

const faker = require('faker');
const FormData = require('form-data');

Expand All @@ -15,6 +17,7 @@ export = () => {
let form = new FormData();
form.append(key, value);
return form;
}
},
...userSteps
});
}
11 changes: 11 additions & 0 deletions stepObjects/userSteps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const userSteps = {
async getUserPerPage(page = 2) {
return this.sendGetRequest(`/api/users?page=${page}`);
},

async getUserById(id: number) {
return this.sendGetRequest(`/api/users/${id}`);
}
}

export default userSteps;

0 comments on commit 042e84d

Please sign in to comment.