fix(misc): move generator should null-check cypress props (#15436)
This commit is contained in:
parent
481899ce9f
commit
46bc6af3c2
@ -59,6 +59,25 @@ describe('updateCypressConfig', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should noop if the videos and screenshots folders are not defined', async () => {
|
||||
const cypressJson = {
|
||||
fileServerFolder: '.',
|
||||
fixturesFolder: './src/fixtures',
|
||||
integrationFolder: './src/integration',
|
||||
pluginsFile: './src/plugins/index',
|
||||
supportFile: false,
|
||||
video: false,
|
||||
chromeWebSecurity: false,
|
||||
};
|
||||
writeJson(tree, '/libs/my-destination/cypress.json', cypressJson);
|
||||
|
||||
updateCypressConfig(tree, schema, projectConfig);
|
||||
|
||||
expect(readJson(tree, '/libs/my-destination/cypress.json')).toEqual(
|
||||
cypressJson
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle updating cypress.config.ts', async () => {
|
||||
tree.write(
|
||||
'/libs/my-destination/cypress.config.ts',
|
||||
|
||||
@ -28,14 +28,20 @@ export function updateCypressConfig(
|
||||
const cypressJson = JSON.parse(
|
||||
tree.read(cypressJsonPath).toString('utf-8')
|
||||
) as PartialCypressJson;
|
||||
cypressJson.videosFolder = cypressJson.videosFolder.replace(
|
||||
project.root,
|
||||
schema.relativeToRootDestination
|
||||
);
|
||||
cypressJson.screenshotsFolder = cypressJson.screenshotsFolder.replace(
|
||||
project.root,
|
||||
schema.relativeToRootDestination
|
||||
);
|
||||
// videosFolder is not required because videos can be turned off - it also has a default
|
||||
if (cypressJson.videosFolder) {
|
||||
cypressJson.videosFolder = cypressJson.videosFolder.replace(
|
||||
project.root,
|
||||
schema.relativeToRootDestination
|
||||
);
|
||||
}
|
||||
// screenshotsFolder is not required as it has a default
|
||||
if (cypressJson.screenshotsFolder) {
|
||||
cypressJson.screenshotsFolder = cypressJson.screenshotsFolder.replace(
|
||||
project.root,
|
||||
schema.relativeToRootDestination
|
||||
);
|
||||
}
|
||||
|
||||
tree.write(cypressJsonPath, JSON.stringify(cypressJson));
|
||||
return tree;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user