Skip to content

Commit 953dc3b

Browse files
committed
jest: mocks already cleared through configuration
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent f27d52d commit 953dc3b

16 files changed

+10
-71
lines changed

__tests__/buildkit/buildkit.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {beforeEach, describe, expect, it, jest, test} from '@jest/globals';
17+
import {describe, expect, it, jest, test} from '@jest/globals';
1818

1919
import {BuildKit} from '../../src/buildkit/buildkit';
2020
import {Builder} from '../../src/buildx/builder';
2121

2222
import {BuilderInfo} from '../../src/types/buildx/builder';
2323

24-
beforeEach(() => {
25-
jest.clearAllMocks();
26-
});
27-
2824
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
2925
return {
3026
name: 'builder2',

__tests__/buildkit/config.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {describe, expect, jest, test, beforeEach, afterEach} from '@jest/globals';
17+
import {describe, expect, jest, test, afterEach} from '@jest/globals';
1818
import * as fs from 'fs';
1919
import * as path from 'path';
2020
import * as rimraf from 'rimraf';
@@ -38,10 +38,6 @@ jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
3838
return tmpName;
3939
});
4040

41-
beforeEach(() => {
42-
jest.clearAllMocks();
43-
});
44-
4541
afterEach(() => {
4642
rimraf.sync(tmpDir);
4743
});

__tests__/buildx/bake.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {afterEach, beforeEach, describe, expect, it, jest, test} from '@jest/globals';
17+
import {afterEach, describe, expect, it, jest, test} from '@jest/globals';
1818
import * as fs from 'fs';
1919
import * as path from 'path';
2020
import * as rimraf from 'rimraf';
@@ -49,10 +49,6 @@ jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
4949
return tmpName;
5050
});
5151

52-
beforeEach(() => {
53-
jest.clearAllMocks();
54-
});
55-
5652
afterEach(() => {
5753
rimraf.sync(tmpDir);
5854
});

__tests__/buildx/build.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
3939
return tmpName;
4040
});
4141

42-
beforeEach(() => {
43-
jest.clearAllMocks();
44-
});
45-
4642
afterEach(() => {
4743
rimraf.sync(tmpDir);
4844
});

__tests__/buildx/builder.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {beforeEach, describe, expect, it, jest, test} from '@jest/globals';
17+
import {describe, expect, it, jest, test} from '@jest/globals';
1818
import * as fs from 'fs';
1919
import * as path from 'path';
2020

@@ -25,10 +25,6 @@ import {BuilderInfo} from '../../src/types/buildx/builder';
2525

2626
const fixturesDir = path.join(__dirname, '..', 'fixtures');
2727

28-
beforeEach(() => {
29-
jest.clearAllMocks();
30-
});
31-
3228
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
3329
return {
3430
name: 'builder2',

__tests__/buildx/buildx.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
4242
return tmpName;
4343
});
4444

45-
beforeEach(() => {
46-
jest.clearAllMocks();
47-
});
48-
4945
afterEach(() => {
5046
rimraf.sync(tmpDir);
5147
});

__tests__/buildx/install.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {describe, expect, it, jest, test, beforeEach, afterEach} from '@jest/globals';
17+
import {describe, expect, it, jest, test, afterEach} from '@jest/globals';
1818
import * as fs from 'fs';
1919
import * as path from 'path';
2020
import * as rimraf from 'rimraf';
@@ -25,10 +25,6 @@ import {Install} from '../../src/buildx/install';
2525
// prettier-ignore
2626
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest');
2727

28-
beforeEach(() => {
29-
jest.clearAllMocks();
30-
});
31-
3228
afterEach(function () {
3329
rimraf.sync(tmpDir);
3430
});

__tests__/context.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import * as fs from 'fs';
1818
import * as path from 'path';
1919
import * as rimraf from 'rimraf';
20-
import {describe, expect, jest, it, beforeEach, afterEach} from '@jest/globals';
20+
import {describe, expect, jest, it, afterEach} from '@jest/globals';
2121

2222
import {Context} from '../src/context';
2323

@@ -36,10 +36,6 @@ jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
3636
return tmpName;
3737
});
3838

39-
beforeEach(() => {
40-
jest.clearAllMocks();
41-
});
42-
4339
afterEach(() => {
4440
rimraf.sync(tmpDir);
4541
});

__tests__/docker/docker.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ const fixturesDir = path.join(__dirname, '..', 'fixtures');
3131
// prettier-ignore
3232
const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-jest');
3333

34-
beforeEach(() => {
35-
jest.clearAllMocks();
36-
});
37-
3834
afterEach(function () {
3935
rimraf.sync(tmpDir);
4036
});

__tests__/docker/install.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ import {Install} from '../../src/docker/install';
2525
// prettier-ignore
2626
const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-install-jest');
2727

28-
beforeEach(() => {
29-
jest.clearAllMocks();
30-
});
31-
3228
afterEach(function () {
3329
rimraf.sync(tmpDir);
3430
});

__tests__/dockerhub.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {describe, expect, jest, it, beforeEach} from '@jest/globals';
17+
import {describe, expect, jest, it} from '@jest/globals';
1818
import * as fs from 'fs';
1919
import * as path from 'path';
2020

2121
import {DockerHub} from '../src/dockerhub';
2222
import {RepositoryResponse, RepositoryTagsResponse} from '../src/types/dockerhub';
2323

24-
beforeEach(() => {
25-
jest.clearAllMocks();
26-
});
27-
2824
import repoInfoFixture from './fixtures/dockerhub-repoinfo.json';
2925
import repoTagsFixture from './fixtures/dockerhub-repotags.json';
3026
import repoAllTagsFixture from './fixtures/dockerhub-repoalltags.json';

__tests__/exec.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {beforeEach, describe, expect, it, jest} from '@jest/globals';
17+
import {describe, expect, it, jest} from '@jest/globals';
1818

1919
import {Exec} from '../src/exec';
2020

21-
beforeEach(() => {
22-
jest.clearAllMocks();
23-
});
24-
2521
describe('exec', () => {
2622
it('returns docker version', async () => {
2723
const execSpy = jest.spyOn(Exec, 'exec');

__tests__/git.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {Exec} from '../src/exec';
2121
import {ExecOutput} from '@actions/exec';
2222

2323
beforeEach(() => {
24-
jest.clearAllMocks();
2524
jest.restoreAllMocks();
2625
});
2726

__tests__/github.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ import * as core from '@actions/core';
2222
import {GitHub} from '../src/github';
2323
import {GitHubRepo} from '../src/types/github';
2424

25-
beforeEach(() => {
26-
jest.clearAllMocks();
27-
});
28-
2925
import repoFixture from './fixtures/github-repo.json';
3026
jest.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => {
3127
return <Promise<GitHubRepo>>(repoFixture as unknown);

__tests__/oci/oci.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {afterEach, beforeEach, describe, expect, jest, test} from '@jest/globals';
17+
import {afterEach, describe, expect, test} from '@jest/globals';
1818
import * as fs from 'fs';
1919
import path from 'path';
2020
import * as rimraf from 'rimraf';
@@ -26,10 +26,6 @@ const fixturesDir = path.join(__dirname, '..', 'fixtures');
2626
// prettier-ignore
2727
const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-jest');
2828

29-
beforeEach(() => {
30-
jest.clearAllMocks();
31-
});
32-
3329
afterEach(function () {
3430
rimraf.sync(tmpDir);
3531
});

__tests__/util.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {beforeEach, describe, expect, it, jest, test} from '@jest/globals';
17+
import {describe, expect, it, test} from '@jest/globals';
1818
import * as fs from 'fs';
1919
import * as path from 'path';
2020

2121
import {Util} from '../src/util';
2222

23-
beforeEach(() => {
24-
jest.clearAllMocks();
25-
});
26-
2723
describe('getInputList', () => {
2824
it('single line correctly', async () => {
2925
await setInput('foo', 'bar');

0 commit comments

Comments
 (0)