Git Product home page Git Product logo

jest-trx-results-processor's People

Contributors

christoment avatar deepakkamboj avatar dependabot-preview[bot] avatar dependabot[bot] avatar dhuacuz avatar elasticpencil avatar greenkeeperio-bot avatar jp7837 avatar nemesv avatar no23reason avatar ssundahl avatar

Stargazers

 avatar  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

jest-trx-results-processor's Issues

codeBase should provide the actual fill path of test suite file

codeBase should provide the actual fill path of test suite file. Currently, codeBase and Name are providing same string.

codeBase should provide name of actual file name of test suite containing the test case.

this can be provided using below code:

   // Build variables for suite name
const filepath = path.relative('./', testRunResult.testFilePath);
const filename = path.basename(filepath);

Only output when run on CI

Configuration

I am using your package tor publish my test results to Azure Devops. The way I am using it is the following:

  • Reference a processor file in package.json, under jest-configuration
"testResultsProcessor": "<rootDir>/jestTrxProcessor.js"
  • The jestTrxProcessor.js-file looks like the following:
var builder = require('jest-trx-results-processor');
var processor = builder({
    outputFile: 'jestTestResults.trx' 
});
module.exports = processor;

Problem

I want to skip processing the trx when running locally. Now it is being run on every test. I instead want it to run only when Azure Devops runs the tests. How is the best way to do this? When reading the readme it states that this is not the prefered way to run your package and will be removed. Does the newer configuration method support running only on CI? Or is that a configuration to set in jest itself?

Switching to reporters API

Jest no longer supports testResultsProcessor (see jest-community/jest-junit#56). Looks like the new configuration syntax should look something like this:

{
  "jest": {
    "reporters": ["default", "jest-trx-results-processor"]
  }
}

or

{
  "jest": {
    "reporters": [
      "default",
      ["jest-trx-results-processor", { "outputFile": "./myFile.trx" }]
    ]
  }
}

I've tried this in Jest 23.6 but it did not produce any outcome, as if jest-trx-results-processor was not used at all. What can be missing?

Any chance I might specify the package name?

It is working well for me.

My results are coming through as package "(root)". Could there be a way, perhaps in the builder({}) object, where I can specify a package name? I might want to put "(Javascript tests)" or something similar there. Alternatively, you could just hard code "Jest tests", perhaps.

Dynamic Filename for TRX using environment variables?

I am using a jest runner that will execute a suite of tests multiple times in parallel. I'd like to be able to have the results-processor output a different trx file for each of these executions, possibly based off an environment variable.

Would it be possible to allow it's output filename to be overwritten as such?

export JEST_TRX_FILE="$BROWSER"-results.trx

"RangeError: Invalid time value" is thrown when the test run contains a skipped testsuit

The following error is throw if you have a test file where are the tests are filtered out with the -t flag:

RangeError: Invalid time value
    at Date.toISOString (<anonymous>)
    at ...\test\node_modules\jest-trx-results-processor\dist\trx-generator.js:121:103
    at Array.forEach (<anonymous>)
    at ...\test\node_modules\jest-trx-results-processor\dist\trx-generator.js:95:37
    at Array.forEach (<anonymous>)
    at Object.exports.generateTrx (...\test\node_modules\jest-trx-results-processor\dist\trx-generator.js:92:31)
    at ...\test\node_modules\jest-trx-results-processor\dist\index.js:11:35
    at processResults (...\test\node_modules\jest-cli\build\run_jest.js:62:55)
    at ...\test\node_modules\jest-cli\build\run_jest.js:155:12
    at Generator.next (<anonymous>)

Jest version: ^21.2.1, jest-trx-results-processor: ^0.0.5

Steps to reproduce: create one spec file with one test

test("first", function () {
	expect(2).toEqual(2);
});

Run the test with a non matching filter e.g. jest -t "second"

Attachments support

During our test runs some of tests might produce some artifacts, like screenshots, logs, etc. Since VSTest supports attachments, I wonder if it would be possible to add this feature to this reporter?

Some info about.

TFS shows 000 milliseconds for test run

I'm trying to integrate this reporter into our Playwright based tests, so we can publish test results in TFS we are hosting, but I face with time reporting issue:

image

Run for 000 milliseconds looks a bit strange.

Same test run reported by JUnit looks better:

image

Can we fix this issue somehow?

require is not a function

I receive a require not defined

TypeError: require(...) is not a function
at processResults (C:\Users\jesse.lay\Desktop\new app\versaweb_2019_edition\node_modules\jest-cli\build\runJest.js:126:55)
at C:\Users\jesse.lay\Desktop\new app\versaweb_2019_edition\node_modules\jest-cli\build\runJest.js:211:12
at Generator.next ()
at step (C:\Users\jesse.lay\Desktop\new app\versaweb_2019_edition\node_modules\jest-cli\build\runJest.js:1:260)
at C:\Users\jesse.lay\Desktop\new app\versaweb_2019_edition\node_modules\jest-cli\build\runJest.js:1:420
at
at process._tickCallback (internal/process/next_tick.js:188:7)

"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js --env=jsdom --json",
"test:ci": "jest --coverage"
},
"jest": {
"testResultsProcessor": "./scripts/jestTrxProcessor",
"collectCoverageFrom": [
"src//*.{js,jsx,mjs}"
],
"setupFiles": [
"/config/polyfills.js"
],
"testMatch": [
"/src/
/tests//*.{js,jsx,mjs}",
"/src/
/?(.)(spec|test).{js,jsx,mjs}"
],
"testEnvironment": "node",
"testURL": "http://localhost",
"transform": {
"^.+\.(js|jsx|mjs)$": "/node_modules/babel-jest",
"^.+\.css$": "/config/jest/cssTransform.js",
"^(?!.
\.(js|jsx|mjs|css|json)$)": "/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\]node_modules[/\\].+\.(js|jsx|mjs)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web"
},
"moduleFileExtensions": [
"web.js",
"js",
"json",
"web.jsx",
"jsx",
"node",
"mjs"
]

Crash on non-existing folder for output file

config

    reporters: [
        'default',
        [
            'jest-trx-results-processor',
            {
                outputFile: 'test_results/resulting.trx', // defaults to "test-results.trx"
                // "defaultUserName": "user name to use if automatic detection fails" // defaults to "anonymous"
            },
        ],
    ],

result

Error: ENOENT: no such file or directory, open 'test_results/resulting.trx'
    at Object.openSync (fs.js:439:3)
    at Object.writeFileSync (fs.js:1190:35)
    at TrxReporter.onRunComplete (.../node_modules/jest-trx-results-processor/dist/index.js:15:18)
    at .../node_modules/jest/node_modules/jest-cli/build/ReporterDispatcher.js:89:27
    at Generator.next (<anonymous>)
    at step (.../node_modules/jest/node_modules/jest-cli/build/ReporterDispatcher.js:13:30)
    at .../node_modules/jest/node_modules/jest-cli/build/ReporterDispatcher.js:24:15
    at process._tickCallback (internal/process/next_tick.js:68:7)

If I create the folder manually before running it works fine.

TypeError: Cannot set property 'onRunComplete' of undefined

Although the test suite passes and the trx file is created successfully, npm gives the following error and makes the pipeline fail:

Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: 7.523s, estimated 8s Ran all test suites. DONE TRX file output to 'test-results.trx' TypeError: Cannot set property 'onRunComplete' of undefined at TrxReporter (C:\Repo\SystemTestsSolution\node_modules\jest-trx-results-processor\dist\index.js:26:28) at Object.<anonymous> (C:\Repo\SystemTestsSolution\jestTrxProcessor.js:3:17) at Module._compile (internal/modules/cjs/loader.js:956:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) at Module.load (internal/modules/cjs/loader.js:812:32) at Function.Module._load (internal/modules/cjs/loader.js:724:14)

test duration isn't accurately reported

It's currently guessed at by claiming that each test of n takes 1/nth of the time of the full suite:

export const getSuitePerTestDuration = (testSuiteResult: TestResult): number =>
  // take the total duration of suite and divide it by the number of tests
  // (Jest does not provide per test performance info)
  Math.floor(
    (testSuiteResult.perfStats.end - testSuiteResult.perfStats.start) /
      (testSuiteResult.numPassingTests +
        testSuiteResult.numFailingTests +
        testSuiteResult.numPendingTests +
        testSuiteResult.numTodoTests),
  );

But it seems the comment is wrong these days, as Jest has an AssertionResult.duration?: number field:

export type AssertionResult = {
  ancestorTitles: Array<string>;
  duration?: Milliseconds | null | undefined;
  failureMessages: Array<string>;
  fullName: string;
  invocations?: number;
  location: Callsite | null | undefined;
  numPassingAsserts: number;
  status: Status;
  title: string;
};

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined

Trying to run jest from command line having reporter set to jest-trx-results-processor

jest --reporters=jest-trx-results-processor

ends up with error

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined at validateString (internal/validators.js:113:11) at Object.resolve (path.js:139:9) at TrxReporter.onRunComplete (C:\Git\client\node_modules\jest-trx-results-processor\dist\index.js:20:67)

"Skipped" is not a valid outcome value and does not match karma-trx-reporter's outcome

Currently, this results processor outputs a "Skipped" outcome for any tests which are marked to be skipped. However, this does not match what karma-trx-reporter outputs or what Visual Studio's api lists (see outcome property of Add test results to a test run section). Both list the outcome should be NotExecuted for skipped tests.

Can we switch the outcome of skipped tests to be NotExecuted instead of Skipped to align with the above? I can submit a PR for this if it sounds good.

startTime is incorrect in trx-generator.ts

        .att(
          "startTime",
          new Date(
            testSuiteResult.perfStats.start + runningDuration,
          ).toISOString(),
        )
        .att(
          "endTime",
          new Date(
            testSuiteResult.perfStats.start + runningDuration,
          ).toISOString(),
        )

Should not add runningDuration for startTime

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.