Skip to content

how to disable core.debug in testing #163

Closed

Description

@tianhaoz95

Is there a way to disable core.debug when I am running jest locally? It is not so helpful to have all the logs on when running regression test.

Activity

  1. added
    question
    on Oct 2, 2019
  2. bryanmacfarlane commented on Oct 2, 2019

    @bryanmacfarlane
    Contributor

    The current model is for the action to emit the output and the runner to conditionally add to logs based on setting.

    Can you clarify whether you want a way to silence during E2E testing or unit testing etc...?

  3. tianhaoz95 commented on Oct 3, 2019

    @tianhaoz95
    Author

    Unit testing. For a node.js action, locally when i run jest --quiet, if I have some core.debug in my code, it will still print out to my console. I am guessing it is because jest doesn't recognize lower level logging. Is there a way that I can set some environment variable ACTION_LOG=false to disable that? I know that setting GitHub action secret can do that, but is there a equivalent locally?

  4. xt0rted commented on Oct 3, 2019

    @xt0rted
    Contributor

    I think this is a duplicate of #118

  5. tianhaoz95 commented on Oct 3, 2019

    @tianhaoz95
    Author

    @xt0rted I think you are right. What is the final decision? jest config or some alternative?

  6. ericsciple commented on Dec 16, 2019

    @ericsciple
    Contributor

    would mocking the core module make more sense?

  7. ericsciple commented on Dec 16, 2019

    @ericsciple
    Contributor

    Example here where core is mocked out specifically to capture info.

    Example here where core is mocked out to control the function results.

    Users can leverage mocking tools to fit their specific needs.

  8. bryanmacfarlane commented on Jan 4, 2020

    @bryanmacfarlane
    Contributor

    Assigning to myself to update docs and guidance pointing to the examples ☝️

  9. thboop commented on Apr 29, 2021

    @thboop
    Collaborator

    dupe of #118

  10. pbrisbin commented on Mar 25, 2026

    @pbrisbin

    Sorry to bump an old issue, but I think this guidance doesn't work since @actions/* has moved to ESM modules.

    I get,

      ● Test suite failed to run
    
        TypeError: Cannot assign to read only property 'info' of object '[object Module]'
    
          at node_modules/jest-mock/build/index.js:622:31
    

    When I use,

    import * as core from "@actions/core";
    import { jest } from "@jest/globals";
    
    jest.spyOn(core, "info");

    There are some more details in jestjs/jest#10025. I've tried various workarounds that didn't work, and ultimately resorted to manual dependency injection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

question

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions