Git Product home page Git Product logo

agent-js-jest's Introduction

Join Slack chat! stackoverflow GitHub contributors Docker Pulls License Build with Love lambdaTest a27c44

Repositories structure

ReportPortal high level architecture

reportportal high level architecture

ReportPortal repositories structure

Report Portal organized into multiple repositories.

ReportPortal server side consists of the following services:

  • service-authorization Authorization Service. In charge of access tokens distribution
  • service-api API Service. Application Backend
  • service-ui UI Service. Application Frontend
  • service-index Index Service. Info and health checks per service.
  • service-analyzer Analyzer Service. Finds most relevant test fail problem.
  • gateway Traefik Gateway Service. Main entry point to application. Port used by gateway should be opened and accessible from outside network.
  • rabbitmq Load balancer for client requests. Bus for messages between servers.
  • minio Attachments storage.

Available plugins developed by ReportPortal team:

Client side adapters related repositories:

  • client-* - API integrations. Http clients, which process HTTP request sending.
  • agent-* - Frameworks integration. Custom reporters/listeners, which monitor test events and trigger event sending via client-*
  • logger-* - Logging integration. Logger appenders, which help to collect logs, bind it with test-case item via agent-* and send to server via client-*

Other repositories stored according to next rules

  • service-* - micro-services which are a part of Application
  • commons-* - common libraries, models, etc., used by micro-services

Installation steps

Simple setup with Docker

It's the best way for demo purposes and small teams. The database is already in the docker-compose.

  1. Install Docker (Engine, Compose)

  2. Download Example of docker-compose descriptor to any folder

  3. Deploy ReportPortal using docker compose plugin within the same folder

docker compose -p reportportal up

To start ReportPortal in daemon mode, add '-d' argument:

docker compose -p reportportal up -d
  1. Open in your browser IP address of deployed environment at port 8080
http://IP_ADDRESS:8080
  1. Use next login\pass for access:
  • default\1q2w3e
  • superadmin\erebus.

Please change admin password for security.

Mentioned compose file deploy all available Bug Tracking System integrations, which not always needed, but use resources.

Production-ready set and Custom deployment with Docker

For production usage, we recommend:

  • choose only required Bug Tracking System integration service. Exclude the rest

To customize deployment and make it production-ready please follow customization steps and details

Integration. How to get log data in

You should add Client Side code inside your test automation. It consists of:

  • client-* - API integrations. Http clients, which process HTTP request sending. E.g. for Java (client-java-*)
  • agent-* - Frameworks integration. Custom reporters/listeners, which monitor test events and trigger event sending via client-*
  • logger-* - Logging integration. Logger appenders, which helps to collect logs, bind it with test-case via agent-* and send to server via client-*

Integration steps and documentation

Contribution

There are many different ways to contribute to Report Portal's development, just find the one that best fits with your skills. Examples of contributions we would love to receive include:

  • Code patches
  • Documentation improvements
  • Translations
  • Bug reports
  • Patch reviews
  • UI enhancements

Big features are also welcome but if you want to see your contributions included in Report Portal codebase we strongly recommend you start by initiating a chat through our Team in Slack.

Contribution details

Documentation

Community / Support

License

Report Portal is Apache 2.0.

agent-js-jest's People

Contributors

a-tanwar avatar aliakseiliasnitski avatar amsterget avatar artsiombandarenka avatar avarabyeu avatar bam6ycha avatar bennbollay avatar chivekrodis avatar dependabot[bot] avatar jonathan-carvalheiro avatar katrin-kot avatar katsiarynatatarynovich avatar leandroeo avatar philgruneich avatar renkyoji avatar ringods avatar ruslanlyubimov avatar tr1ble avatar vladislavakulich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agent-js-jest's Issues

Re-use the same launches when using `jest --shard`

Jest recently introduced--shard option to fasten up tests on CLI.

This option breaks a single run into multiple runs as shown in the image below:

Screenshot 2023-01-10 at 10 43 00 AM

All of these 4 runs are actually part of a single test run on CI and hence same launch ID should be used for all of the individual shard runs.

However, the current behavior is that the package creates 4 different launches and hence 4 different reports on the report portal. Which disturbs the final graph on the report portal.

Skiped status doesn't send to report portal

I run suite with skiped tests. Skiped test marks in ReportPortal as Passed, nut should marked as Skiped.
And how i saw by code you don't send statuses(Failed, Skiped) to the ReportPortal

Attach run results to an existing launch

In order to group multi modules project in one launch, I'd like to be able to attach results to an existing launch on ReportPortal.
Eg:

project:
- module1:
-- jest.conf.js
- module2:
-- jest.conf.js

Each module runs tests separately and I would like to have the results in the same launch.
The agent for Ruby has a feature that allows to do it (it could inspire the development of this new feature).

Duration time under each test suite and test case is always 0s

Duration time under each test suite and test case is always "0s". Problem is identical as in #17 but it doesn't seem to be related to test execution time being too short. I cloned https://github.com/reportportal/examples-js with example-jest and added test with explicit sleep(6000). Seems like last_modified in test_item table and end_time/duration in test_item_results in postgresql are updated too soon.
Duration under launches is ok though.

Cannot find module '../../../jest/node_modules/jest-cli/build/reporters/base_reporter'

Current Behavior

Executing tests results in the following exception:

Error: An error occurred while adding the reporter at path "...\TestApp\node_modules\@reportportal\reportportal-agent-jest\index.js".Cannot find module '../../../jest/node_modules/jest-cli/build/reporters/base_reporter'
    at reporters.forEach.reporter (...\TestApp\node_modules\@jest\core\build\TestScheduler.js:462:15)
    at Array.forEach (<anonymous>)
    at TestScheduler._addCustomReporters (...\TestApp\node_modules\@jest\core\build\TestScheduler.js:450:15)
    at TestScheduler._setupReporters (...\TestApp\node_modules\@jest\core\build\TestScheduler.js:427:12)
    at new TestScheduler (...\TestApp\node_modules\@jest\core\build\TestScheduler.js:172:10)
    at ...\TestApp\node_modules\@jest\core\build\runJest.js:404:29
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (...\TestApp\node_modules\@jest\core\build\runJest.js:150:24)
    at _next (...\TestApp\node_modules\@jest\core\build\runJest.js:170:9)

Possible Explanation

The path to base_reporter appears to have changed somewhere between releases 23.6.0 and 24.0.0 of Jest (there are 10+ alpha releases in there and I didn't feel like checking them all).

Possible Solutions

Change
const base_reporter = require('../../../jest/node_modules/jest-cli/build/reporters/base_reporter');
in jestUtils.js to
const base_reporter = require('../../../@jest/reporters/build/base_reporter');
This of course will break anyone using version <=23.6.0 of Jest.

OR

If you are interested in backwards compatibility you could import some module like fs or path and simply check both paths to determine where the file is located before requiring it.

I'd be happy to submit a pull request if you'd like.

Steps to Reproduce

  1. Complete the Getting Started section using npm (this pretty much just installs jest, adds a .js and a .test.js file and then runs the test).
  2. Follow the README for this repository
  3. Execute npm run test

Please add support for new config item

client-javascript package has added a new config item called restClientConfig. Please add support for this so we can use report portal with self-signed certificates.

Should be possible to add also description in report portal configuration

Hello! Just a suggestion report-portal for jest should have the option to add description in the configuration.

e.g.

{
    "jest": {
        ...
        "reporters": [
            "default",
            ["@reportportal/reportportal-agent-jest",
            {
                "endpoint": "https://your.reportportal.server/api/v1",
                "project": "YourReportPortalProjectName",
                "launchname": "YourLauncherName",
                "description": "YourDescription",
                "tags": ["tag1","tag2"]
            }]
        ],
        ...
    }
}
`` 

Error received while integrating with agent - Request failed with status code 400: {"errorCode":4001,"message":"Incorrect Request. [Field 'name' should not be null.] "} at ....\node_modules\@reportportal\client-javascript\lib\rest.js:31:23 at processTicksAndRejections (internal/process/task_queues.js:97:5)

I am integrating report portal with reportportal-agent-jest.
When I trigger the tests, I start receiving the error
Request failed with status code 400: {"errorCode":4001,"message":"Incorrect Request. [Field 'name' should not be null.] "}
at ....\node_modules@reportportal\client-javascript\lib\rest.js:31:23
at processTicksAndRejections (internal/process/task_queues.js:97:5) The test results are going to report portal but the launch status gets stuck at In Progress.

RP - v5
jest - v 23.4.2
npm module - @reportportal/agent-js-jest
https://github.com/reportportal/agent-js-jest

Please find attached a test project by which you can reproduce the issue.

I also tried by adding the reporter options in package,json in jest but still the results were same.
Test Jest project.zip

Nested Descibe blocks are not coming up and all test shows up in parent describe

I have included actual and expected result for sample test

Inner Describe gets left out and drill down missed in Ui

-----Expected
GET Test Suite
Get the entity used for comparison using google id
Test
gets a response0s
Test
has a defined settings.displayLanguage property0s
Test
has a defined lastLoginDate property0s
Test
has a defined isMailboxSetup property0s
Test
properly combines the family name and given name into the full name0s
Test
has a defined messagesTotal property0s

Get using primary email
Test
gets a response0s
Test
returns a 200 status code0s
Test
returns the proper entity data0s
Test
gets a response0s
Test
gets a response for each alias with the proper body0s
Test
returns a 200 status code0s
Test
returns the proper entity data0s

-----Actual

Expected
GET Test Suite

Test	
gets a response0s
Test	
has a defined settings.displayLanguage property0s
Test	
has a defined lastLoginDate property0s
Test	
has a defined isMailboxSetup property0s
Test	
properly combines the family name and given name into the full name0s
Test	
has a defined messagesTotal property0s

Test	
gets a response0s
Test	
returns a 200 status code0s
Test	
returns the proper entity data0s
Test	
gets a response0s
Test	
gets a response for each alias with the proper body0s
Test	
returns a 200 status code0s
Test	
returns the proper entity data0s

---------------Sample Code

const supertest = require('supertest');
const _ = require('lodash');
const { getHardcodeProps } = require('../../config/jestTests');
let server;

beforeAll(() => {
jest.setTimeout(15000);
server = require('../server');
});
afterAll(() => {
server.close();
});

const { basePath, id, primaryEmail } = getHardcodeProps;

describe(GET Test Suite, async () => {
let sanityObject;
describe('Get the entity used for comparison using google id', async () => {
let res;
it(gets a response, async () => {
res = await supertest(server).get(${basePath}/${id});
expect(res.status).toBe(200);
expect(res.body).toBeDefined();
sanityObject = { ...res.body };
});

it(`has a defined lastLoginDate property`, async () => {
  expect(sanityObject.lastLoginDate).toBeDefined();
});

it(`has a defined settings.displayLanguage property`, async () => {
  expect(sanityObject.settings.displayLanguage).toBeDefined();
});

it(`has a defined isMailboxSetup property`, async () => {
  expect(sanityObject.isMailboxSetup).toBeDefined();
});

it(`properly combines the family name and given name into the full name`, async () => {
  const fullName = _.find(sanityObject.serviceCharacteristic, {
    name: 'fullName',
  });
  const givenName = _.find(sanityObject.serviceCharacteristic, {
    name: 'givenName',
  });
  const familyName = _.find(sanityObject.serviceCharacteristic, {
    name: 'familyName',
  });
  expect(fullName).toBeDefined();
  expect(givenName).toBeDefined();
  expect(familyName).toBeDefined();
  expect(fullName.value).toBe(`${givenName.value} ${familyName.value}`);
});

it(`has a defined messagesTotal property`, async () => {
  expect(sanityObject.messagesTotal).toBeDefined();
});

});

describe('Get using primary email', async () => {
let res;

it(`gets a response`, async () => {
  res = await supertest(server).get(`${basePath}/${primaryEmail}`);
  expect(res.body).toBeDefined();
});

it(`returns a 200 status code`, async () => {
  expect(res.status).toBe(200);
});

it(`returns the proper entity data`, async () => {
  expect(res.body).toEqual(sanityObject);
});

});

describe('Get using the aliases', async () => {
let res;

it(`gets a response for each alias with the proper body`, async () => {
  for (const alias of sanityObject.aliases) {
    res = await supertest(server).get(`${basePath}/${alias}`);
    expect(res.body).toBeDefined();
    expect(res.status).toBe(200);

    //Delete the settings property, as wont be able to retrieve the gmail settings using an alias (must be primary key)
    const getBodyStripped = _.cloneDeep(res.body);
    delete getBodyStripped.settings;
    delete getBodyStripped.messagesTotal;
    const sanityObjectStripped = _.cloneDeep(sanityObject);
    delete sanityObjectStripped.settings;
    delete sanityObjectStripped.messagesTotal;

    expect(getBodyStripped).toMatchObject(sanityObjectStripped);
  }
});

});

describe('Gets only the aliases if passed in fields query parameter', async () => {
let res;

it(`gets a response`, async () => {
  res = await supertest(server).get(`${basePath}/${id}?fields=aliases`);
  expect(res.body).toBeDefined();
});

it(`returns a 200 status code`, async () => {
  expect(res.status).toBe(200);
});

it(`returns the proper entity data`, async () => {
  expect(res.body).toEqual({ aliases: sanityObject.aliases });
});

});

describe('Gets only the primaryEmail if passed in fields query parameter', async () => {
let res;

it(`gets a response`, async () => {
  res = await supertest(server).get(
    `${basePath}/${id}?fields=primaryEmail`
  );
  expect(res.body).toBeDefined();
});

it(`returns a 200 status code`, async () => {
  expect(res.status).toBe(200);
});

it(`returns the proper entity data`, async () => {
  expect(res.body).toEqual({ primaryEmail: sanityObject.primaryEmail });
});

});

describe('Gets both the aliases and the primaryEmail if passed in fields query parameter', async () => {
let res;

it(`gets a response`, async () => {
  res = await supertest(server).get(
    `${basePath}/${id}?fields=primaryEmail,aliases`
  );
  expect(res.body).toBeDefined();
});

it(`returns a 200 status code`, async () => {
  expect(res.status).toBe(200);
});

it(`returns the proper entity data`, async () => {
  expect(res.body).toEqual({
    primaryEmail: sanityObject.primaryEmail,
    aliases: sanityObject.aliases,
  });
});

});
});

Result in Report AI will be

GET Test Suite

Can't set Debug flag

There doesn't seem to be a way to set debug=true like I can with other report portal agents.

I have tried setting it in:

  • jest.config.js
  • With .env flag (I'm assuming, "RP_DEBUG=true")
...
reporters: [
        "default",
        [
            "@reportportal/reportportal-agent-jest",
            {
                "endpoint": "https://report-portal.myurl.io/api/v1",
                "project": "myproject",
                "launchname": "myproject-unit-test",
                "tags": ["cog","unit","react","jest"],
                "debug": true
            }
        ]
    ],
...

Neither method sends test results to the debug view.

The reporter config should include a timeout

If the endpoint of the reportportal agent doesn't respond, the agent could cause a build to hang for a long time. It should be possible to specify a maximum timeout for the agent after which it gives up trying to submit the report and either logs a warning or throws an error.

Receiving Error: connect ECONNREFUSED 127.0.0.1:80

I have report portal up and running on port 8080. I can login to the UI. Per the documents I've added the following config to jest.config.js:

["@reportportal/reportportal-agent-jest", { "token": "2ab677f5-1ca2-49eb-b50b-c7e947b22648", "endpoint": "http://localhost:8080/api/v1", "launchname": "superadmin_TEST_EXAMPLE", "project": "user_service" } ]

On my test run script i execute the following:
npx jest --reporters=@reportportal/reportportal-agent-jest

When the script is run I am receiving the following errors:

{ Error: connect ECONNREFUSED 127.0.0.1:80 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14) errno: 'ECONNREFUSED', code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 80 }

Not certain why it is trying to hit port 80 instead of 8080. So i tried changing the endpoint to something random like https://[email protected]:8080 and it still tries to hit 127.0.0.1:80. So it seems like its not picking up my jest config parameters. I've also tried changing from https to http. Still no difference. Any idea how to troubleshoot this?

NPM

Hi, will this repo be continued? Any plans for updating the npm package?
If not, do you mind if my team proceed creating the new package?

Getting 400 error

Getting below error when using package wit jest

Error: Request failed with status code 400: {"errorCode":4001,"message":"Incorrect Request. [Field 'name' should not be null.] "}
at C:\Sanlam Projects\Automation\node_modules@reportportal\client-javascript\lib\rest.js:36:23

extendTestDescriptionWithLastError option

Hello!

For agent-js-playwright there is extendTestDescriptionWithLastError option. It can be added here too?
Option description: If set to true the last error log will be attached to the test case description and reported on the error log level

Thanks!

Reports test pass even if test failed

Trying to use this reporter to upload test results but in reportportal test shows as passed even if test failed.

package.json

{
  "name": "cookingJest",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "jest"
  },
  "jest": {
    "reporters": [
      "default",
      ["reportportal-agent-jest",
      {
        "endpoint": "https://testreportingsystem-api/v1",
        "project": "cooking",
        "launchname": "YourLauncherName",
        "tags": ["api"]
      }]
    ]
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "axios": "^0.18.0",
    "jest": "^24.1.0",
    "reportportal-agent-jest": "0.0.2"
  },
  "dependencies": {},
  "description": ""
}

test.js

it('test reporter', async function () {
  expect(2 + 1).toBe(4);
})

Env:
node v8.11.2
npm 6.4.1

ReportPortal is showing ANSI shell code chars in execution log

I verified this problem while I investigate an issue alert from ReportPortal about our test executions.

In my setup I have TypeScript + Vue + Testing Library + Jest (with agent-js-jest).

Do someone have some idea with how to solve this problem? Or this is an unexpected behavior for the RP?

image

Cannot connect to ReportPortal

I have followed the guide to configure reportportal/agent-js-jest, but when I run the tests, I get an error:

Error: connect ECONNREFUSED ::1:80
    at /*******/node_modules/@reportportal/client-javascript/lib/rest.js:37:15
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

I have added print out to the console to see the values and this is what I get:

****url: //launch

****method: POST

****data: {"name":"Unit Tests","startTime":1652228835444,"launch":"Unit Tests",
"attributes":[{"key":"agent","value":"@reportportal/agent-js-jest|5.0.3","system":true}
{"key":"client","value":"@reportportal/client-javascript|5.0.6","system":true},
{"key":"os","value":"Darwin|x64","system":true},{"key":"RAMSize","value":17179869184,"system":true},
{"key":"nodeJS","value":"v18.0.0","system":true}]}

****options: {"headers":{"User-Agent":"NodeJS","Authorization":"bearer undefined"}}

Here's my jest.config.js configuration:

reporters: [
    ['@reportportal/agent-js-jest',
    {
      token: '****************************',
      endpoint: 'http://myinstance:8080/api/v1',
      project: 'jest',
      launch: 'Jest Tests',
      description: '',
      skippedIssue: false,
      debug: true,
      restClientConfig: {
        timeout: 5000,
      },
    }],
  ],

I'm not sure where the url is coming from, but clearly it's not coming from the jest.config file.
Any suggestions?

token undefined: Not able to use report portal jest agent :(

Hi Team,
I am not able to use the report portal js agent i am getting the below error
`> jest --no-colors --detectOpenHandles src/tests/api_test.js --config ./jest.config.js

{
error: 'invalid_token',
error_description: 'Invalid access token: undefined'
}
{
error: 'invalid_token',
error_description: 'Invalid access token: undefined'
}
PASS src/tests/api_test.js
โœ“ Overview test (1330 ms)

{
error: 'invalid_token',
error_description: 'Invalid access token: undefined'
}
{
error: 'invalid_token',
error_description: 'Invalid access token: undefined'
}
{
error: 'invalid_token',
error_description: 'Invalid access token: undefined'
}
{
error: 'invalid_token',
error_description: 'Invalid access token: undefined'
}
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.987 s, estimated 3 s
Ran all test suites matching /src/tests/api_test.js/i.
{
error: 'invalid_token',
error_description: 'Invalid access token: undefined'
}`

here is jest.config.js
module.exports = { reporters: [ 'default', [ '@reportportal/reportportal-agent-jest', { token: <token>, endpoint: '<end points>', project: 'patient_api_automation', launch: 'Test', description: 'YourDescription', attributes: [ { key: 'YourKey', value: 'YourValue', }, { value: 'YourValue', }, ], }, ], ],}

Update NPM package

When will the NPM package get updated to the latest version as in this Github repository?

Upload same image that jest report HTML creates

Jest-html reporters provide an addAttach method, with this method I can upload an attachment on fail to see the exact screen where the test failed. Is there any functionality in this agent to do something similar?
Thanks! :)

Not displaying duration time on each test case

Even though the launch shows up the execution time duration for the entire test suit, the individual test cases are not displaying the same information instead are just "0s". Find below the printscreen:

Screen Shot 2019-06-11 at 10 19 04

This items are defined as describes within my test suit. Inside of each test case there are many checks and those don't display the duration time eather.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.