Skip to content

Commit

Permalink
Develop of V2 (#17)
Browse files Browse the repository at this point in the history
* Updated dependencies
* cleaned up testing
* added e2e testing
* updated documentation
* added ci pipeline
* fixed issue with calling done indirectly
* added publish pipeline
* Reformat all code using prettier
Co-authored-by: Pierre Awaragi <[email protected]>
  • Loading branch information
awaragi authored Mar 17, 2022
1 parent 1c0c611 commit f4bfaa5
Show file tree
Hide file tree
Showing 20 changed files with 482 additions and 322 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test
on:
pull_request:
types: [opened, ready_for_review, review_requested, synchronize]
push:
branches: ['master', 'develop']
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
# Defaults to the user or organization that owns the workflow file
scope: '@octocat'
- run: yarn
- run: yarn build
- run: yarn test
env:
DOMAIN: ${{ secrets.DOMAIN }}
USERNAME: ${{ secrets.USERNAME }}
PASSWORD: ${{ secrets.PASSWORD }}
PROJECTID: 1
SUITEID: 1
ASSIGNEDTOID: 1
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Package and publish
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v2
with:
node-version: "14.x"
registry-url: "https://registry.npmjs.org"
# Defaults to the user or organization that owns the workflow file
scope: "@octocat"
- run: yarn
- run: yarn build
- run: yarn test
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
DOMAIN: ${{ secrets.DOMAIN }}
USERNAME: ${{ secrets.USERNAME }}
PASSWORD: ${{ secrets.PASSWORD }}
PROJECTID: 1
SUITEID: 1
ASSIGNEDTOID: 1
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
node_modules
node-debug*
*.log
.c9/
*.iml
.idea/
npm-debug.log
dist
.env
yarn.lock
package-lock.json
12 changes: 9 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
*.iml
.github
.idea/
tsconfig.json
src/
dist/test
*.map
*.iml
tsconfig.json
*.map
*.lock
package-lock.json
.prettier*
.env
*.tgz
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/*
Empty file added .prettierrc
Empty file.
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Pushes test results into Testrail system.

> **NOTE** : Version 2.0.x is backward compatible with v1 but has been updated to latest dependencies. The V2 choice is to ensure that existing users are not affected!
## Installation

```shell
Expand Down Expand Up @@ -32,8 +34,8 @@ mocha --opts mocha-testrail.opts build/test
Mark your mocha test names with ID of Testrail test cases. Ensure that your case ids are well distinct from test descriptions.

```Javascript
it("C123 C124 Authenticate with invalid user", . . .
it("Authenticate a valid user C321", . . .
it("C123 C124 Authenticate with invalid user", () => {})
it("Authenticate a valid user C321", () => {})
```

Only passed or failed tests will be published. Skipped or pending tests will not be published resulting in a "Pending" status in testrail test run.
Expand All @@ -52,6 +54,32 @@ Only passed or failed tests will be published. Skipped or pending tests will not

**assignedToId**: *number* (optional) user id which will be assigned failed tests

## Build and test locally

### Setup testrail test server

- Start a new TestRail trial from https://www.gurock.com/testrail/test-management/
- Enable API under https://XXX.testrail.io/index.php?/admin/site_settings&tab=8
- Add a new project (Use multiple test suites to manage cases)
- Add a new test suite (ids: 1)
- Add at least 4 test cases (ids: C1, C2, C3, C4, etc)
- Once setup, set your environment variables - recommend using .env file in the root folder
- DOMAIN=XXX.testrail.io
- USERNAME=XXX
- PASSWORD=XXX
- PROJECTID=1
- SUITEID=1
- ASSIGNEDTOID=1
- Execute the build and test commands (unit and integration tests)
- Execute the e2e test (requires build and .env file)

### Build and test
```
npm run clean
npm run build
npm run test
```

## References
- http://mochajs.org/#mochaopts
- https://github.com/mochajs/mocha/wiki/Third-party-reporters
Expand Down
3 changes: 3 additions & 0 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package-lock.json
yarn.lock
node_modules
7 changes: 7 additions & 0 deletions e2e/e2e.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
describe("E2E Testrail Mocha Reporter", () => {
it("C1 Test case 1", () => {});
it("C2 Test case 1", () => {});
it("C3 Test case 1", () => {
throw new Error("Failed test");
});
});
16 changes: 16 additions & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "e2e",
"version": "1.0.0",
"description": "E2E test for mocha-testrail-reporter",
"main": "index.js",
"author": "Pierre Awaragi",
"license": "MIT",
"private": true,
"scripts": {
"test": ". ../.env && mocha e2e.spec.js --reporter mocha-testrail-reporter --reporter-options domain=$DOMAIN,username=$USERNAME,password=$PASSWORD,projectId=$PROJECTID,suiteId=$SUITEID"
},
"devDependencies": {
"mocha": "^9.2.2",
"mocha-testrail-reporter": "file:.."
}
}
28 changes: 16 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mocha-testrail-reporter",
"version": "1.0.12",
"description": "A Testrail reporter for mocha including TestRail API basic library",
"version": "2.0.0",
"description": "A Testrail reporter for mocha utilising TestRail API",
"main": "index.js",
"private": false,
"keywords": [
Expand All @@ -23,24 +23,28 @@
"url": "https://github.com/awaragi/mocha-testrail-reporter/issues"
},
"scripts": {
"tsc": "tsc",
"build": "tsc",
"clean": "rimraf dist",
"test": "mocha dist/test",
"build": "npm run clean && npm run tsc"
"test:ts": "mocha -r ts-node/register src/test/*",
"format": "prettier --check ./**/* --write"
},
"dependencies": {
"btoa": "^1.1.2",
"unirest": "^0.5.1"
"unirest": "^0.6.0"
},
"peerDependencies": {
"mocha": "^3 || ^2.2.5"
"mocha": "9.2.2"
},
"devDependencies": {
"@types/chai": "^3.4.34",
"@types/mocha": "^2.2.36",
"@types/node": "^6.0.58",
"chai": "^3.5.0",
"rimraf": "^2.5.4",
"typescript": "^2.1.4"
"@types/chai": "^4.3.0",
"@types/mocha": "^9.1.0",
"@types/node": "^12.20.47",
"chai": "^4.3.6",
"mocha": "^9.2.2",
"prettier": "^2.6.0",
"rimraf": "^3.0.2",
"ts-node": "^10.7.0",
"typescript": "^4.6.2"
}
}
Loading

0 comments on commit f4bfaa5

Please sign in to comment.