netsuite-suitecloud-sdk
netsuite-suitecloud-sdk copied to clipboard
Jest Custom Output not working, seems the configuration for JEST is not getting passed in correctly
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:
- 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.
@Rvice Can you share a complete package.json?
Which version of team-city-reporter are yo using?
@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
Thanks @Rvice. Is this still an issue?
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?
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
}
Closing this issue as the jest.config.js steps above fixed it.