Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
fix: tests fs mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
arantespp committed Feb 23, 2022
1 parent 9661fae commit a00350a
Show file tree
Hide file tree
Showing 5 changed files with 3,358 additions and 5,527 deletions.
3 changes: 2 additions & 1 deletion packages/cli/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
collectCoverage: true,
coverageThreshold: {
global: {
branches: 32,
branches: 30,
functions: 54,
lines: 59,
statements: 62,
Expand All @@ -11,4 +11,5 @@ module.exports = {
preset: 'ts-jest',
setupFiles: ['<rootDir>/setupTests.js'],
silent: true,
timers: 'fake',
};
1 change: 1 addition & 0 deletions packages/cli/src/deploy/lambda.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const existsSyncMock = jest.fn((input) => {
});

jest.mock('fs', () => ({
...(jest.requireActual('fs') as any),
existsSync: existsSyncMock,
}));

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/deploy/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const deployLambdaLayers = async ({
)}] was found. Creating other layers...`,
);

const { dependencies } = (() => {
const { dependencies = {} } = (() => {
try {
// eslint-disable-next-line global-require, import/no-dynamic-require
return require(path.resolve(process.cwd(), 'package.json')) || {};
Expand Down
10 changes: 2 additions & 8 deletions packages/cli/src/deploy/staticApp/staticApp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

import { DescribeStackResourceCommand } from '@aws-sdk/client-cloudformation';
import * as faker from 'faker';
import * as fs from 'fs';

// const readFileSyncMock = jest.fn();

// jest.mock('fs', () => ({
// readFileSync: readFileSyncMock,
// }));
import fs from 'fs';

import { AWS_DEFAULT_REGION } from '../../config';

Expand Down Expand Up @@ -54,7 +48,7 @@ jest.mock('@aws-sdk/client-cloudformation', () => ({
})),
}));

jest.mock('fs');
// jest.mock('fs');

jest.mock('../cloudFormation.core', () => ({
...(jest.requireActual('../cloudFormation.core') as any),
Expand Down
Loading

0 comments on commit a00350a

Please sign in to comment.