Test coverage using jest-junit fails in a create-react-app project












0















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?










share|improve this question

























  • 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
















0















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?










share|improve this question

























  • 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














0












0








0








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?










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 14:50









skyboyer

3,44111128




3,44111128










asked Nov 14 '18 at 8:03









seniorquicoseniorquico

131211




131211













  • 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





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












1 Answer
1






active

oldest

votes


















0














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.






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    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.






    share|improve this answer




























      0














      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.






      share|improve this answer


























        0












        0








        0







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 9:03









        seniorquicoseniorquico

        131211




        131211






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()