oracle / netsuite-suitecloud-sdk

SuiteCloud Software Development Kit (SuiteCloud SDK) are the set of tools that allow you to customize accounts and create SuiteApps through SuiteCloud Development Framework (SDF).
https://www.netsuite.com/
Universal Permissive License v1.0
202 stars 62 forks source link

Jest Custom Output not working, seems the configuration for JEST is not getting passed in correctly #391

Closed Rvice closed 1 year ago

Rvice commented 3 years ago

Your environment

OS Windows 10 Node.js version : v16.5.0 suitecloud-cli version : 1.2.1 Terminal/CMD tool : CMD

Describe the bug

I am attempting to use a custom reporter (https://www.npmjs.com/package/jest-teamcity-reporter), but it appears I cannot get the configuration settings to apply.

To Reproduce

Steps to reproduce the behavior:

  1. Add the following to the package.json "script": { jest --converage }, "jest": { "testResultsProcessor": "jest-teamcity-reporter" }

Actual Behavior

Standard output

Expected Behavior

Expect to see TeamCity like outputs, but instead get the standard output. These include tags with the ##teamcity style output.

Additional context

I am trying to use a custom formatter to send unit test results to TeamCity for pass/fail reporting. The workaround is to use the --json option in the "script" and looking for that in the string of failedtests:0 not matching.

I tried to modify the jest.config.js to include the options with the module.export, but that breaks everything else.

I then tried to add the Options in the suitecloud.config.js where the comment // Jest configuration options. exists without any luck as well.

Might be user error here as I am not completely familiar with Jest and how the module exports work. If I could just find the appropriate location for adding the Jest configurations that might resolve this issue.

alisyed-19 commented 3 years ago

@Rvice Can you share a complete package.json?

Which version of team-city-reporter are yo using?

Rvice commented 3 years ago

@Rvice Can you share a complete package.json?

Which version of team-city-reporter are yo using?

jest-teamcity-reporter 0.9.0

Here's the bulk of the package.json

{  "scripts": {
    "test": "jest --json --coverage"
  },
  "dependencies": {
    "ts-node": "^9.0.0",
    "canvas": "^2.6.0",
    "bufferutil": "^4.0.1",
    "utf-8-validate": "^5.0.2",
    "typescript": "^2.7"
  },
  "devDependencies": {
    "@oracle/suitecloud-unit-testing": "^1.1.3",
    "jest": "^26.6.3",
    "jest-teamcity-reporter": "^0.9.0"
  },
  "jest": {
    "testResultsProcessor": "jest-teamcity-reporter",
    "coverageReporters": [
      "lcov",
      "text",
      "teamcity"
    ]
  }}

Maybe I'm missing something obvious

tourajvaziri commented 2 years ago

Thanks @Rvice. Is this still an issue?

Rvice commented 1 year ago

I see where the problem comes in, it's in the jest.config.js

 module.exports = SuiteCloudJestConfiguration.build({
    projectFolder: cliConfig.defaultProjectFolder,
    projectType: SuiteCloudJestConfiguration.ProjectType.ACP,
    testEnvironment : 'node',
    testResultsProcessor: "jest-teamcity",
    coverageReporters: [
    "lcov",
    "text",
    "teamcity"
    ],
    reporters: ["default", "jest-teamcity"]
});

If I move the reporters/testResultsProcessor/etc as the module.exports then it works. How can I get these additional config parameters to Jest? Is there a "passthrough" part of the SutieCloudJestConfiguration.build?

Rvice commented 1 year ago

This may have resolved the issue in the jest.config.js

const nsExport = SuiteCloudJestConfiguration.build({
    projectFolder: cliConfig.defaultProjectFolder,
    projectType: SuiteCloudJestConfiguration.ProjectType.ACP
});

const jestParams = {
    "testEnvironment" : "node",
    "testResultsProcessor": "jest-teamcity",
    "coverageReporters": [
        "lcov",
        "text",
        "teamcity"
    ],
    "reporters" : ["default", "jest-teamcity"]
};

module.exports = {
    ...nsExport,
    ...jestParams
}
Rvice commented 1 year ago

Closing this issue as the jest.config.js steps above fixed it.