Skip to content

Commit

Permalink
FI-1300 feat: add writeOnly flag to "full mocks" config
Browse files Browse the repository at this point in the history
  • Loading branch information
uid11 committed May 25, 2024
1 parent 9231b41 commit ff4b7f3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions autotests/configurator/fullMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const fullMocks: FullMocks = {

return JSON.parse(testFullMocksJson) as TestFullMocks;
},
writeOnly: false,
writeTestFullMocks: async (testId, testFullMocks) => {
const testFullMocksJson = JSON.stringify(testFullMocks);

Expand Down
5 changes: 5 additions & 0 deletions src/types/fullMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export type FullMocksConfig<TestMeta = TestMetaPlaceholder> = Readonly<{
*/
readTestFullMocks: (this: void, testId: FullMocksTestId) => Promise<TestFullMocks | undefined>;

/**
* If `true`, then only writes mocks (but do not apply).
*/
writeOnly: boolean;

/**
* Writes full mocks of one test by `testId`.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/utils/fullMocks/enableFullMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const enableFullMocks = async (

let testFullMocks: TestFullMocks | undefined;

if (shouldApplyMocks) {
if (shouldApplyMocks && !fullMocksConfig.writeOnly) {
testFullMocks = await fullMocksConfig.readTestFullMocks(fullMocksState.testId);
}

Expand Down

0 comments on commit ff4b7f3

Please sign in to comment.