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

jasmineMessage: Uncaught exception: Error: Request failed with status code 404: {"errorCode":4043,"message":"Test Item '4463a494-839b-45e2-bfe2-00d03a20aa12' not found. Did you use correct Test Item ID?"}[v5] #82

Closed
mleonard0826 opened this issue May 4, 2020 · 3 comments

Comments

@mleonard0826
Copy link

mleonard0826 commented May 4, 2020

I'm running a custom jasmine.js file to execute my tests. It goes as follows:

jasmine.js

var Jasmine = require('jasmine');
var jasmine = new Jasmine();

const ReportportalAgent = require('agent-js-jasmine');
const currentDate = new Date();

function formatDate(date) {
    var d = new Date(date),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
        year = d.getFullYear();

    if (month.length < 2) 
        month = '0' + month;
    if (day.length < 2) 
        day = '0' + day;

    return [year, month, day].join('-');
}

const agent = new ReportportalAgent({
    token: "6df05ba5-98b5-4203-9106-a5867be16113",
    endpoint: "http://localhost:8080/api/v1",
    launch: "superadmin_REACT APP UNIT " + formatDate(currentDate),
    project: "sampleprojects"
});

jasmine.loadConfigFile('spec/support/jasmine.json');

jasmine.configureDefaultReporter({
    showColors: false
});

jasmine.addReporter(agent.getJasmineReporter());
jasmine.execute();

jasmine.onComplete(function(passed) {
    if(passed) {
        console.log('All specs have passed.');
    }
    else {
        console.log('At least one spec has failed');
    }
});

agent.getExitPromise().then(() => {
    console.log('finish work');
});

package.json

{
  "name": "default-react-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "node jasmine.js",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "agent-js-jasmine": "^3.0.0",
    "jasmine": "^3.5.0",
    "jest": "^25.5.4"
  }
}

If I comment out the last three lines, or include them in the jasmine.onComplete() method, and execute npm test, I run into a situation where my test run never finishes according to ReportPortal, and only the passed tests appear in the count on the UI.

Conversely, if I include them as indicated in the block above, I get the Uncaught Exception referenced in the title of this bug.

Using Mac OS X, Chrome.

@mleonard0826
Copy link
Author

I should probably have posted this to the agent-js-jasmine repo...

@KatsiarynaTatarynovich
Copy link
Contributor

Hi @mleonard0826
The method agent.getExitPromise has to be called anyway. You just should change the way you call it.
This error occurred as the launch had finished before the test item started. So you need to wrap jasmine.execute and jasmine.onComplete in Promise and inside of the method then() you should call the agent.getExitPromise method.
As an example

const executeJasmine = function() {
    return new Promise( (resolve, reject) => {
        jasmine.execute();
        jasmine.onComplete(function(status) {
            resolve(status);
        });
    });
};

executeJasmine().then((passed) => {
    agent.getExitPromise().then(() => {
        console.log('finish work');
    });

    if(passed) {
        console.log('All specs have passed');
    }
    else {
        console.log('At least one spec has failed');
    }
});

Also, wish to note the necessity of adding the attachPicturesToLogs with value false to the configuration of the agent. Otherwise, you will catch the error.

@mleonard0826
Copy link
Author

Thank you! That solved my problem.

@AmsterGet AmsterGet transferred this issue from reportportal/reportportal Jun 1, 2023
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

No branches or pull requests

2 participants