Skip to content

Commit

Permalink
Merge pull request #210 from dmitry-shibanov/v-dmshib/suppress-test-l…
Browse files Browse the repository at this point in the history
…og-output

Suppress warning/debug/info output from tests
  • Loading branch information
MaksimZhukov authored Aug 23, 2021
2 parents c21fb93 + 30cd52e commit 3bc31aa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions __tests__/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import io = require('@actions/io');
import fs = require('fs');
import path = require('path');
import * as core from '@actions/core';
import os from 'os';

import * as auth from '../src/auth';
Expand All @@ -10,11 +11,14 @@ const settingsFile = path.join(m2Dir, auth.SETTINGS_FILE);

describe('auth tests', () => {
let spyOSHomedir: jest.SpyInstance;
let spyInfo: jest.SpyInstance;

beforeEach(async () => {
await io.rmRF(m2Dir);
spyOSHomedir = jest.spyOn(os, 'homedir');
spyOSHomedir.mockReturnValue(__dirname);
spyInfo = jest.spyOn(core, 'info');
spyInfo.mockImplementation(() => null);
}, 300000);

afterAll(async () => {
Expand Down
13 changes: 13 additions & 0 deletions __tests__/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ describe('dependency cache', () => {
let workspace: string;
let spyInfo: jest.SpyInstance<void, Parameters<typeof core.info>>;
let spyWarning: jest.SpyInstance<void, Parameters<typeof core.warning>>;
let spyDebug: jest.SpyInstance<void, Parameters<typeof core.debug>>;
let spySaveState: jest.SpyInstance<void, Parameters<typeof core.saveState>>;

beforeEach(() => {
workspace = mkdtempSync(join(tmpdir(), 'setup-java-cache-'));
Expand All @@ -38,7 +40,16 @@ describe('dependency cache', () => {

beforeEach(() => {
spyInfo = jest.spyOn(core, 'info');
spyInfo.mockImplementation(() => null);

spyWarning = jest.spyOn(core, 'warning');
spyWarning.mockImplementation(() => null);

spyDebug = jest.spyOn(core, 'debug');
spyDebug.mockImplementation(() => null);

spySaveState = jest.spyOn(core, 'saveState');
spySaveState.mockImplementation(() => null);
});

afterEach(() => {
Expand All @@ -58,6 +69,7 @@ describe('dependency cache', () => {
spyCacheRestore = jest
.spyOn(cache, 'restoreCache')
.mockImplementation((paths: string[], primaryKey: string) => Promise.resolve(undefined));
spyWarning.mockImplementation(() => null);
});

it('throws error if unsupported package manager specified', () => {
Expand Down Expand Up @@ -117,6 +129,7 @@ describe('dependency cache', () => {
spyCacheSave = jest
.spyOn(cache, 'saveCache')
.mockImplementation((paths: string[], key: string) => Promise.resolve(0));
spyWarning.mockImplementation(() => null);
});

it('throws error if unsupported package manager specified', () => {
Expand Down
4 changes: 4 additions & 0 deletions __tests__/cleanup-java.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as util from '../src/util';

describe('cleanup', () => {
let spyWarning: jest.SpyInstance<void, Parameters<typeof core.warning>>;
let spyInfo: jest.SpyInstance<void, Parameters<typeof core.info>>;
let spyCacheSave: jest.SpyInstance<
ReturnType<typeof cache.saveCache>,
Parameters<typeof cache.saveCache>
Expand All @@ -13,6 +14,9 @@ describe('cleanup', () => {

beforeEach(() => {
spyWarning = jest.spyOn(core, 'warning');
spyWarning.mockImplementation(() => null);
spyInfo = jest.spyOn(core, 'info');
spyInfo.mockImplementation(() => null);
spyCacheSave = jest.spyOn(cache, 'saveCache');
spyJobStatusSuccess = jest.spyOn(util, 'isJobStatusSuccess');
spyJobStatusSuccess.mockReturnValue(true);
Expand Down

0 comments on commit 3bc31aa

Please sign in to comment.