Skip to content

Commit

Permalink
chore: mocking the version number to make the tests deterministic (#1…
Browse files Browse the repository at this point in the history
…9089)

Because the actual version of the CLI depends on the context ("0.0.0" on the dev environment, actual version on the pipeline etc), we have to mock the return value of the function to make the tests deterministic.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
otaviomacedo committed Feb 22, 2022
1 parent d37fbbb commit d325004
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/aws-cdk/test/notices.test.ts
Expand Up @@ -10,6 +10,7 @@ import {
Notice,
WebsiteNoticeDataSource,
} from '../lib/notices';
import * as version from '../lib/version';

const BASIC_NOTICE = {
title: 'Toggling off auto_delete_objects for Bucket empties the bucket',
Expand Down Expand Up @@ -45,6 +46,16 @@ const FRAMEWORK_2_1_0_AFFECTED_NOTICE = {
};

describe('cli notices', () => {
beforeAll(() => {
jest
.spyOn(version, 'versionNumber')
.mockImplementation(() => '1.0.0');
});

afterAll(() => {
jest.restoreAllMocks();
});

describe(formatNotices, () => {
test('correct format', () => {
const result = formatNotices([BASIC_NOTICE])[0];
Expand Down

0 comments on commit d325004

Please sign in to comment.