Skip to content

Commit

Permalink
Merge pull request #77 from joomcode/feature/add-writeOnly-for-fullMocks
Browse files Browse the repository at this point in the history
feat: add `writeOnly` flag to "full mocks" config
  • Loading branch information
uid11 committed May 27, 2024
2 parents 9231b41 + 56d2f47 commit 4ec8166
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
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
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"dependencies": {
"bin-v8-flags-filter": "1.2.0",
"create-locator": "0.0.20",
"create-locator": "0.0.23",
"get-modules-graph": "0.0.9",
"globby": "11.1.0",
"pngjs": "7.0.0",
Expand All @@ -37,7 +37,7 @@
"@typescript-eslint/parser": "7.10.0",
"assert-modules-support-case-insensitive-fs": "1.0.1",
"assert-package-lock-is-consistent": "1.0.0",
"devtools-protocol": "0.0.1302984",
"devtools-protocol": "0.0.1306150",
"eslint": "8.57.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "9.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/createLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export {
} from 'create-locator';
export type {PARAMETERS} from 'create-locator/oldTypes';
// eslint-disable-next-line import/no-internal-modules
export {createLocatorCreatorInTests} from 'create-locator/createLocatorCreatorInTests';
export {createSelectorFunctions} from 'create-locator/createSelectorFunctions';
// eslint-disable-next-line import/no-internal-modules
export {getCssSelectorFromAttributesChain} from 'create-locator/getCssSelectorFromAttributesChain';
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 4ec8166

Please sign in to comment.