Test coverage using jest-junit fails in a create-react-app project
In a create-react-app/react-scripts@2.1.1 project, I'm trying to generate a coverage report using jest-junit. Unfortunately, it fails with the following:
$ yarn run test --coverage
Failed to write coverage reports:
ERROR: Error: Invalid report format [jest-junit]
STACK: Error: Invalid report format [jest-junit]
at Object.module.exports.create (D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibinput-error.js:6:15)
at Reporter.add (D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibreporter.js:51:30)
at D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibreporter.js:62:18
at Array.forEach (<anonymous>)
at Reporter.addAll (D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibreporter.js:61:14)
at D:UsersusernameDocumentsProjectnode_modulesjest-clibuildreporterscoverage_reporter.js:180:18
at Generator.next (<anonymous>)
at step (D:UsersusernameDocumentsProjectnode_modulesjest-clibuildreporterscoverage_reporter.js:75:30)
at D:UsersusernameDocumentsProjectnode_modulesjest-clibuildreporterscoverage_reporter.js:86:15
at process._tickCallback (internal/process/next_tick.js:68:7)
I encounter no errors if I run yarn run test
. The following configuration block was added to the project's package.json
file:
...
"jest":
"collectCoverageFrom": [
"src/**/*.js,jsx,ts,tsx",
"!src/**/*.d.ts",
"!src/**/__stories__/",
"!<rootDir>/node_modules/"
],
"coverageReporters": [
"jest-junit"
]
...
Has anyone successfully configured jest-junit in a create-react-app@2 project?
jestjs create-react-app
add a comment |
In a create-react-app/react-scripts@2.1.1 project, I'm trying to generate a coverage report using jest-junit. Unfortunately, it fails with the following:
$ yarn run test --coverage
Failed to write coverage reports:
ERROR: Error: Invalid report format [jest-junit]
STACK: Error: Invalid report format [jest-junit]
at Object.module.exports.create (D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibinput-error.js:6:15)
at Reporter.add (D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibreporter.js:51:30)
at D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibreporter.js:62:18
at Array.forEach (<anonymous>)
at Reporter.addAll (D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibreporter.js:61:14)
at D:UsersusernameDocumentsProjectnode_modulesjest-clibuildreporterscoverage_reporter.js:180:18
at Generator.next (<anonymous>)
at step (D:UsersusernameDocumentsProjectnode_modulesjest-clibuildreporterscoverage_reporter.js:75:30)
at D:UsersusernameDocumentsProjectnode_modulesjest-clibuildreporterscoverage_reporter.js:86:15
at process._tickCallback (internal/process/next_tick.js:68:7)
I encounter no errors if I run yarn run test
. The following configuration block was added to the project's package.json
file:
...
"jest":
"collectCoverageFrom": [
"src/**/*.js,jsx,ts,tsx",
"!src/**/*.d.ts",
"!src/**/__stories__/",
"!<rootDir>/node_modules/"
],
"coverageReporters": [
"jest-junit"
]
...
Has anyone successfully configured jest-junit in a create-react-app@2 project?
jestjs create-react-app
Your configuration doesn't seem to match what's shown on the jest-junit page, why have you diverged from that?
– jonrsharpe
Nov 14 '18 at 8:27
add a comment |
In a create-react-app/react-scripts@2.1.1 project, I'm trying to generate a coverage report using jest-junit. Unfortunately, it fails with the following:
$ yarn run test --coverage
Failed to write coverage reports:
ERROR: Error: Invalid report format [jest-junit]
STACK: Error: Invalid report format [jest-junit]
at Object.module.exports.create (D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibinput-error.js:6:15)
at Reporter.add (D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibreporter.js:51:30)
at D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibreporter.js:62:18
at Array.forEach (<anonymous>)
at Reporter.addAll (D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibreporter.js:61:14)
at D:UsersusernameDocumentsProjectnode_modulesjest-clibuildreporterscoverage_reporter.js:180:18
at Generator.next (<anonymous>)
at step (D:UsersusernameDocumentsProjectnode_modulesjest-clibuildreporterscoverage_reporter.js:75:30)
at D:UsersusernameDocumentsProjectnode_modulesjest-clibuildreporterscoverage_reporter.js:86:15
at process._tickCallback (internal/process/next_tick.js:68:7)
I encounter no errors if I run yarn run test
. The following configuration block was added to the project's package.json
file:
...
"jest":
"collectCoverageFrom": [
"src/**/*.js,jsx,ts,tsx",
"!src/**/*.d.ts",
"!src/**/__stories__/",
"!<rootDir>/node_modules/"
],
"coverageReporters": [
"jest-junit"
]
...
Has anyone successfully configured jest-junit in a create-react-app@2 project?
jestjs create-react-app
In a create-react-app/react-scripts@2.1.1 project, I'm trying to generate a coverage report using jest-junit. Unfortunately, it fails with the following:
$ yarn run test --coverage
Failed to write coverage reports:
ERROR: Error: Invalid report format [jest-junit]
STACK: Error: Invalid report format [jest-junit]
at Object.module.exports.create (D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibinput-error.js:6:15)
at Reporter.add (D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibreporter.js:51:30)
at D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibreporter.js:62:18
at Array.forEach (<anonymous>)
at Reporter.addAll (D:UsersusernameDocumentsProjectnode_modulesistanbul-apilibreporter.js:61:14)
at D:UsersusernameDocumentsProjectnode_modulesjest-clibuildreporterscoverage_reporter.js:180:18
at Generator.next (<anonymous>)
at step (D:UsersusernameDocumentsProjectnode_modulesjest-clibuildreporterscoverage_reporter.js:75:30)
at D:UsersusernameDocumentsProjectnode_modulesjest-clibuildreporterscoverage_reporter.js:86:15
at process._tickCallback (internal/process/next_tick.js:68:7)
I encounter no errors if I run yarn run test
. The following configuration block was added to the project's package.json
file:
...
"jest":
"collectCoverageFrom": [
"src/**/*.js,jsx,ts,tsx",
"!src/**/*.d.ts",
"!src/**/__stories__/",
"!<rootDir>/node_modules/"
],
"coverageReporters": [
"jest-junit"
]
...
Has anyone successfully configured jest-junit in a create-react-app@2 project?
jestjs create-react-app
jestjs create-react-app
edited Nov 14 '18 at 14:50
skyboyer
3,56611128
3,56611128
asked Nov 14 '18 at 8:03
seniorquicoseniorquico
131311
131311
Your configuration doesn't seem to match what's shown on the jest-junit page, why have you diverged from that?
– jonrsharpe
Nov 14 '18 at 8:27
add a comment |
Your configuration doesn't seem to match what's shown on the jest-junit page, why have you diverged from that?
– jonrsharpe
Nov 14 '18 at 8:27
Your configuration doesn't seem to match what's shown on the jest-junit page, why have you diverged from that?
– jonrsharpe
Nov 14 '18 at 8:27
Your configuration doesn't seem to match what's shown on the jest-junit page, why have you diverged from that?
– jonrsharpe
Nov 14 '18 at 8:27
add a comment |
1 Answer
1
active
oldest
votes
Thanks to @jonrsharpe for the quick comment. I wasn't paying close enough attention... my mistake was dropping jest-junit into coverageReporters (as opposed to reporters).
Unfortunately, create-react-app@2 does not appear to support a custom reporters configuration in package.json. Interestingly, the following command works:
$ yarn run test --coverage --reporters=default --reporters=jest-junit
I'm used to most of create-react-app's configs overriding any explicitly defined options. However, it appears an exception (or loophole?) exists for yarn run test
. With the above, I get the desired junit.xml file.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53295486%2ftest-coverage-using-jest-junit-fails-in-a-create-react-app-project%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks to @jonrsharpe for the quick comment. I wasn't paying close enough attention... my mistake was dropping jest-junit into coverageReporters (as opposed to reporters).
Unfortunately, create-react-app@2 does not appear to support a custom reporters configuration in package.json. Interestingly, the following command works:
$ yarn run test --coverage --reporters=default --reporters=jest-junit
I'm used to most of create-react-app's configs overriding any explicitly defined options. However, it appears an exception (or loophole?) exists for yarn run test
. With the above, I get the desired junit.xml file.
add a comment |
Thanks to @jonrsharpe for the quick comment. I wasn't paying close enough attention... my mistake was dropping jest-junit into coverageReporters (as opposed to reporters).
Unfortunately, create-react-app@2 does not appear to support a custom reporters configuration in package.json. Interestingly, the following command works:
$ yarn run test --coverage --reporters=default --reporters=jest-junit
I'm used to most of create-react-app's configs overriding any explicitly defined options. However, it appears an exception (or loophole?) exists for yarn run test
. With the above, I get the desired junit.xml file.
add a comment |
Thanks to @jonrsharpe for the quick comment. I wasn't paying close enough attention... my mistake was dropping jest-junit into coverageReporters (as opposed to reporters).
Unfortunately, create-react-app@2 does not appear to support a custom reporters configuration in package.json. Interestingly, the following command works:
$ yarn run test --coverage --reporters=default --reporters=jest-junit
I'm used to most of create-react-app's configs overriding any explicitly defined options. However, it appears an exception (or loophole?) exists for yarn run test
. With the above, I get the desired junit.xml file.
Thanks to @jonrsharpe for the quick comment. I wasn't paying close enough attention... my mistake was dropping jest-junit into coverageReporters (as opposed to reporters).
Unfortunately, create-react-app@2 does not appear to support a custom reporters configuration in package.json. Interestingly, the following command works:
$ yarn run test --coverage --reporters=default --reporters=jest-junit
I'm used to most of create-react-app's configs overriding any explicitly defined options. However, it appears an exception (or loophole?) exists for yarn run test
. With the above, I get the desired junit.xml file.
answered Nov 14 '18 at 9:03
seniorquicoseniorquico
131311
131311
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53295486%2ftest-coverage-using-jest-junit-fails-in-a-create-react-app-project%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Your configuration doesn't seem to match what's shown on the jest-junit page, why have you diverged from that?
– jonrsharpe
Nov 14 '18 at 8:27