Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add the Mocha reporter #633

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
max-parallel: 5
matrix:
node-version: [ '16', '18' ]
prefix: [ "qaseio", "qase-javascript-commons", "qase-cypress", "qase-cucumberjs", "qase-newman", "qase-testcafe", "qase-jest", "qase-playwright" ]
prefix: [ "qaseio", "qase-javascript-commons", "qase-cypress", "qase-cucumberjs", "qase-newman", "qase-testcafe", "qase-jest", "qase-playwright", "qase-mocha" ]
name: Project ${{ matrix.prefix }} - Node ${{ matrix.node-version }}
steps:
- uses: actions/checkout@v2
Expand All @@ -27,7 +27,7 @@ jobs:
strategy:
max-parallel: 5
matrix:
prefix: [ "qaseio", "qase-javascript-commons", "qase-cypress", "qase-cucumberjs", "qase-newman", "qase-testcafe", "qase-jest", "qase-playwright" ]
prefix: [ "qaseio", "qase-javascript-commons", "qase-cypress", "qase-cucumberjs", "qase-newman", "qase-testcafe", "qase-jest", "qase-playwright", "qase-mocha" ]
if: startsWith(github.event.ref, 'refs/tags')
name: Publish ${{ matrix.prefix }}
steps:
Expand Down
4 changes: 4 additions & 0 deletions examples/mocha/.mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
spec: ["test/*.spec.js"],
reporter: "mocha-qase-reporter"
};
11 changes: 11 additions & 0 deletions examples/mocha/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "examples-mocha",
"private": true,
"scripts": {
"test": "QASE_MODE=testops mocha"
},
"devDependencies": {
"mocha": "^10.2.0",
"mocha-qase-reporter": "^1.0.0-beta.1"
}
}
17 changes: 17 additions & 0 deletions examples/mocha/qase.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"debug": true,

"testops": {
"api": {
"token": "token"
},

"project": "project_code",
"uploadAttachments": true,

"run": {
"complete": true,
"title": "Mocha test run"
}
}
}
14 changes: 14 additions & 0 deletions examples/mocha/test/attachTests.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const assert = require('assert');


describe('tests with attachments', function() {
it('successful test with string attachment', function() {
this.attach({name:"attachment.log", content:"data", contentType:"text/plain"});
assert.strictEqual(1, 1);
});

it('failing test with string attachment', function() {
this.attach({name:"attachment.log", content:"data", contentType:"text/plain"});
assert.strictEqual(1, 2);
});
});
99 changes: 99 additions & 0 deletions examples/mocha/test/simpleTests.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
const assert = require('assert');


describe('test without qase metadata', function() {
it('successful test', function() {
assert.strictEqual(1, 1);
});

it('failing test', function() {
assert.strictEqual(1, 2);
});
});

describe('test with qase id', function() {
it('successful test', function() {
this.qaseId(1);
assert.strictEqual(1, 1);
});

it('failing test', function() {
this.qaseId(2);
assert.strictEqual(1, 2);
});
});

describe('test with title', function() {
it('successful test', function() {
this.title('Successful test with title');
assert.strictEqual(1, 1);
});

it('failing test', function() {
this.title('Failing test with title');
assert.strictEqual(1, 2);
});
});

describe('test with suite', function() {
it('successful test', function() {
this.suite('Suite 1');
assert.strictEqual(1, 1);
});

it('failing test', function() {
this.suite('Suite 1');
assert.strictEqual(1, 2);
});
});

describe('test with comment', function() {
it('successful test', function() {
this.comment('comment');
assert.strictEqual(1, 1);
});

it('failing test', function() {
this.comment('comment');
assert.strictEqual(1, 2);
});
});

describe('test with parameters', function() {
const params = [1, 2, 3, 4, 5];
params.forEach((param) => {
it(`successful test with parameter ${param}`, function() {
this.parameters({ number: param });
assert.strictEqual(param, param);
});
it(`failing test with parameter ${param}`, function() {
this.parameters({ number: param });
assert.strictEqual(param, param + 1);
});
});
});


describe('test with fields', function() {
it('successful test', function() {
this.fields({ custom_field: 'value' });
assert.strictEqual(1, 1);
});

it('failing test', function() {
this.fields({ custom_field: 'value' });
assert.strictEqual(1, 2);
});
});

describe('ignored test', function() {
it('successful test', function() {
this.ignore();
assert.strictEqual(1, 1);
});

it('failing test', function() {
this.ignore();
assert.strictEqual(1, 2);
});
});
19 changes: 19 additions & 0 deletions examples/mocha/test/stepsTests.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const assert = require('assert');


describe('tests with steps', function() {
it('successful test with steps', function() {
this.step('step 1', function() {
this.attach({name:"attachment.log", content:"data", contentType:"text/plain"});
});
this.step('step 2', function() {});
this.attach({name:"attachment111.log", content:"data", contentType:"text/plain"});
assert.strictEqual(1, 1);
});

it('failing test with steps', function() {
this.step('step 1', function() {});
this.step('step 2', function() {});
assert.strictEqual(1, 2);
});
});
Loading
Loading