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

Add unit tests and GitHub Actions step to run them #49

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

vs4vijay
Copy link
Owner

@vs4vijay vs4vijay commented Aug 1, 2024

Related to #35

Add unit tests and GitHub Actions workflow for influxdb-reporter.

  • Unit Tests

    • Create test/influxdb-reporter.test.js to test InfluxDBReporter class.
    • Test initialization, start, beforeItem, request, assertion, item, and done methods.
    • Mock necessary objects and functions for testing.
  • GitHub Actions Workflow

    • Add .github/workflows/main.yml to define CI workflow.
    • Include steps to checkout repository, set up Node.js, install dependencies, build, and run unit tests.
  • package.json

    • Update scripts section to include "test": "jest".
    • Add jest as a dev dependency.

Related to #35

Add unit tests and GitHub Actions workflow for `influxdb-reporter`.

* **Unit Tests**
  - Create `test/influxdb-reporter.test.js` to test `InfluxDBReporter` class.
  - Test initialization, `start`, `beforeItem`, `request`, `assertion`, `item`, and `done` methods.
  - Mock necessary objects and functions for testing.

* **GitHub Actions Workflow**
  - Add `.github/workflows/main.yml` to define CI workflow.
  - Include steps to checkout repository, set up Node.js, install dependencies, build, and run unit tests.

* **package.json**
  - Update `scripts` section to include `"test": "jest"`.
  - Add `jest` as a dev dependency.
});

it('should update currentItem data for skipped assertion', function() {
const args = { skipped: true, assertion: 'Test Assertion' };
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).


describe('assertion', function() {
it('should update currentItem data for failed assertion', function() {
const error = { test: 'Test Assertion', name: 'AssertionError', message: 'Test failed' };
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

const args = {
cursor: {},
item: { name: 'Test Item' },
request: { url: { toString: () => 'http://example.com' }, method: 'GET' },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').


describe('request', function() {
it('should update currentItem data', function() {
const args = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

let reporter;
let newmanEmitter;
let reporterOptions;
let options;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

describe('InfluxDBReporter', function() {
let reporter;
let newmanEmitter;
let reporterOptions;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).


describe('InfluxDBReporter', function() {
let reporter;
let newmanEmitter;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

const InfluxDBReporter = require('../src/influxdb-reporter');

describe('InfluxDBReporter', function() {
let reporter;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

@@ -0,0 +1,104 @@
const assert = require('assert');
const InfluxDBReporter = require('../src/influxdb-reporter');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

@@ -0,0 +1,104 @@
const assert = require('assert');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

Copy link

sonarcloud bot commented Aug 1, 2024

@vs4vijay vs4vijay merged commit 49ccbca into develop Aug 1, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant